main
md 54 lines 2.5 KB
Rendered Raw
1 # context.py DOX
2
3 ## Purpose
4
5 - Own the `context.py` helper module.
6 - This module provides compatibility helpers for reading and writing `AgentContext` data.
7 - Keep this file-level DOX profile synchronized with `context.py` because this directory is intentionally flat.
8
9 ## Ownership
10
11 - `context.py` owns the runtime implementation.
12 - `context.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
13 - Top-level functions:
14 - `_ensure_context() -> Dict[str, Any]`: Make sure a context dict exists, and return it.
15 - `set_context_data(key: str, value: Any)`: Set context data for the current async/task context.
16 - `delete_context_data(key: str)`: Delete a key from the current async/task context.
17 - `get_context_data(key: Optional[str]=..., default: T=...) -> T`: Get a key from the current context, or the full dict if key is None.
18 - `clear_context_data()`: Completely clear the context dict.
19 - Notable constants/configuration names: `T`.
20
21 ## Runtime Contracts
22
23 - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together.
24 - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change.
25 - Observed side-effect areas: filesystem deletion, scheduler state.
26 - Imported dependency areas include: `contextvars`, `typing`.
27
28 ## Key Concepts
29
30 - Important called helpers/classes observed in the source: `TypeVar`, `ContextVar`, `_ensure_context`, `cast`.
31 - Keep request/response, tool, or helper semantics documented here at the same time as source changes.
32
33 ## Work Guidance
34
35 - Preserve public helper APIs used by core code and plugins unless every caller is updated.
36 - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded.
37 - Prefer adding cohesive helper functions here only when behavior is reused across modules.
38
39 ## Verification
40
41 - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers.
42 - Related tests observed by source search:
43 - `tests/test_a0_connector_prompt_gating.py`
44 - `tests/test_api_chat_lifetime.py`
45 - `tests/test_browser_agent_regressions.py`
46 - `tests/test_document_query_plugin.py`
47 - `tests/test_error_retry_plugin.py`
48 - `tests/test_extensions_stress.py`
49 - `tests/test_file_tree_visualize.py`
50 - `tests/test_history_compression_wait.py`
51
52 ## Child DOX Index
53
54 No child DOX files.