Skip to content

fix(agency): clear disabled team context to prevent stale roster leakage#99

Closed
DeployFaith wants to merge 1 commit into
mainfrom
codex/propose-fix-for-stale-team-context
Closed

fix(agency): clear disabled team context to prevent stale roster leakage#99
DeployFaith wants to merge 1 commit into
mainfrom
codex/propose-fix-for-stale-team-context

Conversation

@DeployFaith

Copy link
Copy Markdown
Owner

Motivation

  • A prior change skipped calling manager.cached_team_context() when agency.team.inject_context was false, which prevented prompt-hook inclusion but also skipped the refresh/clear path that would overwrite stale state.team_context.
  • Because NodeState.as_dict() serializes team_context and the agency_start_node/agency_stop_node tools return that serialized state, a stale, attacker-controlled roster block could be exposed to model-callable tool output after injection was disabled.
  • The goal is to avoid reading cached roster text when injection is disabled while still ensuring any previously cached team context is cleared so it cannot be serialized and leaked.

Description

  • Add NodeManager.clear_team_context(config: AgencyConfig | None = None) which clears self.state.team_context and sets self.state.config appropriately.
  • Keep the prompt hook from reading the cached roster when inject_context is false but call manager.clear_team_context(cfg) to explicitly remove any stale cached context instead of skipping the clearing side-effect.
  • Redact team_context in NodeState.as_dict() by returning self.team_context if self.config.team.inject_context else "" so serialized state never includes a stale roster when injection is disabled.
  • Add regression tests to verify the hook does not read the cached roster when disabled but does clear state, and to verify serialized NodeState redacts team_context when inject_context is false.

Testing

  • Ran targeted unit tests: python -m pytest hermes-agency/tests/test_unit.py -q -m "not integration" -k "team_context_hook or node_state_as_dict" and the targeted tests passed (2 tests executed, both passed in the targeted run).
  • Ran style checks: ruff check . and ruff format --check . and both returned clean results.
  • Ran broader unit test subset: python -m pytest hermes-agency/tests/test_unit.py -q -m "not integration" which ran many tests; non-async tests completed but the environment lacks an async pytest plugin so async tests failed with the expected plugin-related error; the new regression tests are sync and passed.
  • Note: repository-root Node/npm checks (npm run lint, npm run typecheck, npm test) were not runnable in this environment because there is no package.json at repo root, and python -m pytest hermes-agency/tests/test_keryx_transport.py includes async tests that require an async plugin (so they failed in this environment).

Codex Task

@DeployFaith

Copy link
Copy Markdown
Owner Author

Superseded by #101, merged to main as 4133675 after all required GitHub checks passed.

@DeployFaith
DeployFaith deleted the codex/propose-fix-for-stale-team-context branch July 17, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant