Skip to content

feat(agent): add AgentProfile + ContextVar for per-agent paths (1/6)#37495

Open
davidgut1982 wants to merge 1 commit into
NousResearch:mainfrom
davidgut1982:feat/mga-1-agent-profile
Open

feat(agent): add AgentProfile + ContextVar for per-agent paths (1/6)#37495
davidgut1982 wants to merge 1 commit into
NousResearch:mainfrom
davidgut1982:feat/mga-1-agent-profile

Conversation

@davidgut1982

Copy link
Copy Markdown
Contributor

What

Add AgentProfile dataclass and a ContextVar so per-agent filesystem paths and identity resolve correctly under concurrent gateway tasks.

Why

Multi-agent routing needs each in-flight message to resolve its own agent's paths/config without threading an explicit argument through every call site; a ContextVar gives task-local agent binding.

How to test

python -m pytest tests/agent/test_profile_contextvar.py -q

Platforms tested

Linux (CT 133 / Proxmox LXC)

Part 1 of 6 in the multi-agent gateway decomposition (replaces #34741). First in the chain — based directly on main.

Introduce AgentProfile dataclass and a ContextVar (_current_agent_profile)
that lets path getters (get_hermes_home, get_skills_dir, get_memory_dir)
resolve to the active agent's home directory under asyncio.

- agent/profile.py: AgentProfile, use_profile() context manager,
  load_agent_registry() from GatewayConfig
- hermes_constants.py: get_hermes_home() reads ContextVar before env fallback
- tests/agent/test_profile_contextvar.py: ContextVar isolation under
  asyncio.gather, nested contexts, registry loading

Single-agent installs see zero change — no profile bound means fallback
to HERMES_HOME env var as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants