main
md 48 lines 2.45 KB
Rendered Raw
1 # agent_profile_set.py DOX
2
3 ## Purpose
4
5 - Own the `agent_profile_set.py` API endpoint.
6 - This module sets the active agent profile for a chat context and returns profile label metadata.
7 - Keep this file-level DOX profile synchronized with `agent_profile_set.py` because this directory is intentionally flat.
8
9 ## Ownership
10
11 - `agent_profile_set.py` owns the runtime implementation.
12 - `agent_profile_set.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
13 - Classes:
14 - `SetAgentProfile` (`ApiHandler`)
15 - `async process(self, input: dict, request: Request) -> dict | Response`
16
17 ## Runtime Contracts
18
19 - HTTP handlers must derive from `helpers.api.ApiHandler`; WebSocket handlers must derive from `helpers.ws.WsHandler`.
20 - Update this file whenever request payloads, authentication or CSRF requirements, response shapes, route side effects, or WebSocket event contracts change.
21 - `SetAgentProfile` is an `ApiHandler`.
22 - `SetAgentProfile` defines `process(...)`.
23 - Observed side-effect areas: filesystem writes, settings/state persistence.
24 - Switching a chat profile updates the context and top-level agent profile only; existing subordinate agents keep their own profile configs.
25 - A profile can be selected only when it is available in the chat's active
26 project scope; profiles owned by other projects are not valid candidates.
27 - Imported dependency areas include: `agent`, `helpers`, `helpers.api`, `helpers.persist_chat`, `helpers.state_monitor_integration`.
28
29 ## Key Concepts
30
31 - Important called helpers/classes observed in the source: `str.strip`, `context.is_running`, `initialize_agent`, `context.agent0.config`, `save_tmp_chat`, `mark_dirty_for_context`, `projects.get_context_project_name`, `subagents.get_available_agents_dict`, `Response`.
32 - Keep request/response, tool, or helper semantics documented here at the same time as source changes.
33
34 ## Work Guidance
35
36 - Preserve authentication, CSRF, loopback, and API-key checks unless the endpoint contract explicitly changes.
37 - Update frontend callers, plugin callers, and tests together when payload shape changes.
38 - Use `helpers.api.Response` for non-JSON responses, files, redirects, or status-specific replies.
39
40 ## Verification
41
42 - Run endpoint-specific or API/WebSocket tests for changed behavior; smoke-test browser callers when no focused test exists.
43 - Related tests observed by source search:
44 - `tests/test_subagent_profiles.py`
45
46 ## Child DOX Index
47
48 No child DOX files.