feat(agent,gateway): cross-mode fallback context bridge + Inspector server - #43289
feat(agent,gateway): cross-mode fallback context bridge + Inspector server#43289cjakma wants to merge 1 commit into
Conversation
…erver - Add fallback_context_bridge to strip provider-specific fields (codex reasoning blobs) and rebuild the system prompt when api_mode changes during failover (e.g. codex_responses → anthropic_messages) - Set _pending_context_bridge flag in try_activate_fallback and consume it in conversation_loop before the next retry request - Add read-only Inspector server (gateway/inspector.py) with opt-in startup in start_gateway; configurable via HERMES_INSPECTOR_HOST/PORT - Fix providers.py: use base_url_hostname() for api.openai.com detection to prevent false matches on URLs containing the string as a substring - Fix skills_tool strategy-3 flat search to skip files nested inside another skill's SKILL.md directory (reference assets, not standalone) - Add simulation/trigger scripts and integration test for fallback bridge Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment (High Surface Area)
Scope
- 2,485 additions, 4 deletions across 15+ files — this is a significant new feature introducing a cross-mode fallback context bridge and an Inspector debug server.
Security
- The new
/config/publicendpoint explicitly strips sensitive keys (api_key,token,secret,password,auth,credential,bearer) — good security posture. - The Inspector server binds to
127.0.0.1:8646by default and can be configured viainspector.host/inspector.port— appropriate for a local-only debug tool. - One concern: The
_SENSITIVE_KEY_PATTERNSregex approach may miss edge cases (e.g., nested keys, case variations). Consider validating against a known list of sensitive field names in addition to pattern matching.
Code Quality
- The diff contains curl commands with pipe-to-python in comments (lines 168-170) — these appear to be development notes left in the code. Consider removing before merge.
print()statements in the bridge implementation (lines 1205, 1252) look like debug leftovers.- The module is well-structured with clear separation between the fallback bridge, Inspector server, and session management.
Performance
- The Inspector server spawns a new asyncio server per call to
start_inspector_server()— if this is called repeatedly, it could leave orphan servers. Verify cleanup on shutdown.
Suggestion
- Add a test for the
/config/publicendpoint to ensure sensitive keys are actually filtered in all code paths.
Reviewed by Hermes Agent
|
Thanks for the PR! A few observations: 1. Stray file in the diff — This 528-line Korean-language changelog document doesn't appear to be part of the codebase. It's a local documentation file describing the changes in this PR and general contributing guidelines. It should be removed before merging — it will pollute the repo root. 2. Inspector server CORS policy when bound to The Inspector server sets Consider either:
3. PR bundles four unrelated changes The PR description and diff include: (a) fallback context bridge, (b) Inspector server, (c) |
|
Closing this PR in response to review feedback. Split into 4 focused PRs:
Also removed |
What changed and why
feat(agent): Cross-mode fallback context bridge
When the
api_modechanges during failover (e.g.codex_responses→anthropic_messages), the existingapi_messagescarry provider-specific fields (codex reasoning items, encrypted blobs) that the new provider rejects. This PR detects the mode change intry_activate_fallback, sets_pending_context_bridgeon the agent, and appliesfallback_context_bridge.apply_fallback_context_bridge()inconversation_loopbefore the retry request. The bridge strips the stale provider-specific fields and clears the cached system prompt so it rebuilds with current skill context for the new provider.feat(gateway): Read-only Inspector server
Adds
gateway/inspector.py— a lightweight read-only HTTP meta-API that external containers (sidecars, monitoring tools) can query for gateway state without touching the main gateway socket. Enabled by default; opt out withHERMES_INSPECTOR_DISABLED=1. Host/port configurable viaHERMES_INSPECTOR_HOST/HERMES_INSPECTOR_PORT(default127.0.0.1:8646).fix(providers): Use hostname for api.openai.com detection
determine_api_modewas usingin url_lowerstring containment which could match URLs that merely containapi.openai.comas a substring. Switched tobase_url_hostname(base_url) == "api.openai.com"for exact hostname matching.fix(tools): Exclude nested skill docs from strategy-3 flat search
skill_viewstrategy-3 (rglob) was picking up reference/template.mdfiles nested inside another skill's directory. Added an ancestor-walk check to skip any file whose parent chain contains aSKILL.mdbetween it and the search root.How to test
Fallback bridge:
Inspector server:
Provider fix:
Skills fix:
Platforms tested
Notes
notion-backup-slack-thread-2026-05-15.mdis intentionally excluded (internal file)