Local Development
When developing A2A agents, it's essential to test your agent locally before deploying to Health Universe. The SDK provides local development tools that simulate the production environment without requiring backend services.
This guide shows you how to set up and test your agents locally using the LocalDocumentClient and create_local_context.
Overview
Local development with A2A agents allows you to:
Test agent logic without deploying to Health Universe
Work with local test files instead of cloud storage
Debug your agent's document processing capabilities
Validate input/output behavior in isolation
The SDK provides two key utilities for local testing:
LocalDocumentClient: Filesystem-backed document operationscreate_local_context: Factory for creating test contexts
Setting Up Local Test Data
Directory Structure
Create a local test data directory with the following structure:
test_data/
├── source/ # Input documents (user uploads)
│ ├── protocol.pdf
│ ├── data.csv
│ └── notes.txt
└── artifact/ # Pre-seeded outputs (optional)
└── example.jsonThe SDK will automatically create these directories if they don't exist.
Supported File Types
The LocalDocumentClient works with any file type, but for realistic testing, use files similar to what users will upload:
PDFs: Clinical protocols, research papers
CSV: Patient data, lab results
JSON: Structured medical data
TXT/MD: Clinical notes, documentation
Creating a Local Context
The simplest way to create a local test environment is using create_local_context():
Testing Your Agent Locally
Basic Local Testing
Here's a complete example of testing an agent locally:
Advanced Local Testing
For more sophisticated testing, you can create the LocalDocumentClient directly:
Working with Different File Types
Text Files
For text-based files (CSV, JSON, TXT, MD), use download_text():
Binary Files
For binary files (PDF, images, etc.), use download():
Creating Test Output
Write various output formats to test different scenarios:
Limitations of Local Mode
When testing locally, be aware of these limitations:
Search Not Available
Full-text and semantic search are not available in local mode:
No Text Extraction Pipeline
Local mode doesn't have the platform's text extraction pipeline:
Progress Updates Are Logged Only
Progress updates are logged to stdout instead of being sent to the backend:
Best Practices
Organize Test Data
Keep your test data organized and representative:
Test Error Conditions
Include problematic files to test error handling:
Validate Output Structure
Check that your agent produces the expected output format:
Moving from Local to Production
Once your agent works locally, deploying to production should be seamless:
Keep the same agent code - no changes needed
Replace local context with production
AgentContextRemove local test code - the production environment handles context creation
Test with real data - upload test files to your Health Universe thread
The context.document_client API works identically in both local and production modes, so your document processing code remains the same.
Example: Complete Local Development Workflow
Here's a complete example showing the full local development workflow:
Save this as test_local.py and run it to test your agent locally before deployment.
This local development approach lets you iterate quickly, debug issues, and ensure your agent works correctly before deploying to Health Universe.
Last updated
Was this helpful?