feat(transports): add opt-in extra_body.hermes outbound metadata channel#27525
feat(transports): add opt-in extra_body.hermes outbound metadata channel#27525konsisumer wants to merge 1 commit into
Conversation
|
Rebased onto origin/main and resolved the in-scope conflict in Verification:
|
ea255c0 to
f424780
Compare
|
Rebased onto current origin/main and resolved the in-scope conflict in Verification:
|
f424780 to
6a2f90e
Compare
|
Thanks for the focused implementation — I verified the requested Problems
Suggested changes
This is an automated hermes-sweeper review. |
6a2f90e to
9dd96f8
Compare
|
Thanks for the review. Addressed in this push:
Related: #22714. |
What changed and why
Adds a documented
extra_body.hermesobject to every outgoing chat-completions request whenextras.hermes_metadata.enabled: trueis set inconfig.yaml(default: false).This gives downstream OpenAI-compatible proxies and dispatchers (LiteLLM, Helicone, Langfuse, custom routers) machine-readable orchestration context — session, platform, chat, user, command origin — without parsing free text or spinning up one Hermes profile per channel.
Per the confirmed direction on #22714:
/modelstays as the human-facing lever;extra_body.hermesis the parallel machine-facing channel (pure addition, no removal).extra_body.hermesnamespace consistent with existingextra_body.{provider,thinking,reasoning,plugins}shape inagent/transports/chat_completions.py, and generalises thesession_idplumbing already shipped via perf(models_dev): cache-first lookup, skip network when disk cache is fresh #22808/fix(openrouter): add x-grok-conv-id header for Grok models (carve-out of #22708) #22809 for Grok.session_id,gateway_platform,chat_id,user_id,command_origin. Fields whose runtime value isNoneare omitted so the flag is safe to enable even when some fields are unavailable (e.g.,chat_idon the CLI).user_intentdeferred to v2 (requires a classifier, not just plumbing).Field names mirror
SessionSource.chat_id/AIAgent.__init__kwargs for naming consistency, and align with @gsskk's inbound-headers PR #24423 (X-Hermes-Chat-Id↔extra_body.hermes.chat_id).Files changed
agent/transports/chat_completions.py_add_hermes_metadata()helper; called from both profile and legacy pathsagent/chat_completion_helpers.pyhermes_outbound_metadata+ four context fields tobuild_kwargs()agent/agent_init.pyhermes_outbound_metadata: boolandcommand_origin: strparamsrun_agent.pyinit_agent()gateway/run.pyextras.hermes_metadata.enabledfrom config; pass to both agent creation sites (command_origin="user"for main flow,"scheduled"for background tasks)docs/hermes-outbound-metadata.mdtests/agent/transports/test_chat_completions.pyHow to test
{ "extra_body": { "hermes": { "session_id": "<session-id>", "gateway_platform": "matrix", "chat_id": "!room:example.org", "user_id": "@alice:example.org", "command_origin": "user" } } }enabled: false(default), confirm noextra_body.hermeskey appears.enabled: false— requests must succeed unchanged.Unit test coverage:
pytest tests/agent/transports/test_chat_completions.py::TestHermesOutboundMetadata -vWhat platforms tested on
TestHermesOutboundMetadatatests passtest_background_command,test_discord_component_auth,test_auxiliary_client,test_platform_commands,test_registry_manifest) confirmed pre-existing viagit stashbisectFixes #22714