| 1 | # fasta2a_server.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `fasta2a_server.py` helper module. |
| 6 | - This module serves Agent Zero through a dynamic A2A proxy. |
| 7 | - Keep this file-level DOX profile synchronized with `fasta2a_server.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `fasta2a_server.py` owns the runtime implementation. |
| 12 | - `fasta2a_server.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Classes: |
| 14 | - `AgentZeroFastA2A` (`FastA2A`) |
| 15 | - `async _agent_card_endpoint(self, request: Request) -> StarletteResponse` |
| 16 | - `AgentZeroWorker` (`Worker`) |
| 17 | - `async run_task(self, params: Any) -> None` |
| 18 | - `async cancel_task(self, params: Any) -> None` |
| 19 | - `build_message_history(self, history: List[Any]) -> List[Message]` |
| 20 | - `build_artifacts(self, result: Any) -> List[Artifact]` |
| 21 | - `DynamicA2AProxy` (no explicit base class) |
| 22 | - `get_instance()` |
| 23 | - `reconfigure(self, token: str)` |
| 24 | - Top-level functions: |
| 25 | - `_enable_streaming_capability(agent_card_body: bytes) -> bytes`: Ensure the generated A2A agent card advertises streaming support. |
| 26 | - `is_available()`: Check if FastA2A is available and properly configured. |
| 27 | - `get_proxy()`: Get the FastA2A proxy instance. |
| 28 | - Notable constants/configuration names: `_PRINTER`. |
| 29 | |
| 30 | ## Runtime Contracts |
| 31 | |
| 32 | - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together. |
| 33 | - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change. |
| 34 | - Agent Zero wraps `FastA2A` with `AgentZeroFastA2A` so the generated agent card sets `capabilities.streaming` to `true` by default. |
| 35 | - Observed side-effect areas: filesystem writes, filesystem deletion, settings/state persistence, secret handling, scheduler state. |
| 36 | - Imported dependency areas include: `agent`, `asyncio`, `atexit`, `contextlib`, `helpers`, `helpers.persist_chat`, `helpers.print_style`, `initialize`, `json`, `starlette.requests`, `starlette.responses`, `threading`, `typing`, `uuid`. |
| 37 | |
| 38 | ## Key Concepts |
| 39 | |
| 40 | - Important called helpers/classes observed in the source: `PrintStyle`, `DynamicA2AProxy.get_instance`, `json.loads`, `json.dumps`, `super.__init__`, `super._agent_card_endpoint`, `join`, `UserMessage`, `threading.Lock`, `atexit.register`, `self._configure`, `settings.get_settings`, `path.startswith`, `self._convert_message`, `initialize_agent`, `AgentContext`, `context.log.log`, `context.communicate`, `context.reset`, `AgentContext.remove`, `remove_chat`, `self.storage.update_task`, `self._register_shutdown`. |
| 41 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 42 | |
| 43 | ## Work Guidance |
| 44 | |
| 45 | - Preserve public helper APIs used by core code and plugins unless every caller is updated. |
| 46 | - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded. |
| 47 | - Prefer adding cohesive helper functions here only when behavior is reused across modules. |
| 48 | |
| 49 | ## Verification |
| 50 | |
| 51 | - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers. |
| 52 | - Related tests: |
| 53 | - `tests/test_fasta2a_server.py` |
| 54 | |
| 55 | ## Child DOX Index |
| 56 | |
| 57 | No child DOX files. |