fix(agency): clear disabled team context to prevent stale roster leakage#99
Closed
DeployFaith wants to merge 1 commit into
Closed
fix(agency): clear disabled team context to prevent stale roster leakage#99DeployFaith wants to merge 1 commit into
DeployFaith wants to merge 1 commit into
Conversation
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
manager.cached_team_context()whenagency.team.inject_contextwas false, which prevented prompt-hook inclusion but also skipped the refresh/clear path that would overwrite stalestate.team_context.NodeState.as_dict()serializesteam_contextand theagency_start_node/agency_stop_nodetools return that serialized state, a stale, attacker-controlled roster block could be exposed to model-callable tool output after injection was disabled.Description
NodeManager.clear_team_context(config: AgencyConfig | None = None)which clearsself.state.team_contextand setsself.state.configappropriately.inject_contextis false but callmanager.clear_team_context(cfg)to explicitly remove any stale cached context instead of skipping the clearing side-effect.team_contextinNodeState.as_dict()by returningself.team_context if self.config.team.inject_context else ""so serialized state never includes a stale roster when injection is disabled.NodeStateredactsteam_contextwheninject_contextis false.Testing
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).ruff check .andruff format --check .and both returned clean results.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.npm run lint,npm run typecheck,npm test) were not runnable in this environment because there is nopackage.jsonat repo root, andpython -m pytest hermes-agency/tests/test_keryx_transport.pyincludes async tests that require an async plugin (so they failed in this environment).Codex Task