Skip to content

feat(hermes-v2): inject team/agent identity headers for asset registration - #905

Open
TreyDong wants to merge 1 commit into
TencentCloud:feat/serverfrom
TreyDong:feat/hermes-v2-team-agent-headers
Open

feat(hermes-v2): inject team/agent identity headers for asset registration#905
TreyDong wants to merge 1 commit into
TencentCloud:feat/serverfrom
TreyDong:feat/hermes-v2-team-agent-headers

Conversation

@TreyDong

Copy link
Copy Markdown

Problem

The v2 Hermes provider (memory_tencentdb_v2) builds the MemoryClient without any team/agent identity. Every conversation write therefore reaches the Gateway without x-tdai-team-id / x-tdai-agent-id headers.

The Gateway's automatic chat_memory asset registration (v2-router.tsensureChatMemoryAsset) is gated on those headers being present:

if (deps.getMetadataService && iso?.teamId && iso?.agentId) { ... ensureChatMemoryAsset(...) }

So with the stock v2 plugin, no per-agent memory asset is ever registered and the Team Memory Control panel shows no Chat Memory assets for Hermes users — even though conversations are recorded fine.

Fix

Inject x-tdai-team-id / x-tdai-agent-id on every SDK request by constructing a custom HttpStub backed by an httpx.Client with default headers. Two new optional env vars (both default to "default", matching the standalone convention):

  • TDAI_MEMORY_TEAM_ID
  • TDAI_MEMORY_AGENT_ID

If the custom-stub path is unavailable (SDK layout changes), the provider falls back to the plain client — behavior preserved.

Verification (standalone Gateway, remote endpoint)

  • Before: sync_turn() writes L0/L1 fine, meta_assets stays empty for the Hermes agent.
  • After: one sync_turn() immediately registers chat_memory-<team>-<agent> in meta_assets, and the panel bootstrap API (/api/v1/agent-overview/bootstrap) returns it under chatMemories.

…ation

The v2 Hermes provider (memory_tencentdb_v2) constructs the SDK client
without team/agent identity, so every conversation write goes through the
Gateway without x-tdai-team-id / x-tdai-agent-id headers. As a result the
Gateway's automatic chat_memory asset registration (v2-router
ensureChatMemoryAsset, gated on those headers) never fires, and the
Team Memory Control panel shows no per-agent memory assets for Hermes
users.

Inject the headers via a custom HttpStub carrying an httpx.Client with
default headers, sourced from two new env vars:

  TDAI_MEMORY_TEAM_ID  (default: "default")
  TDAI_MEMORY_AGENT_ID (default: "default")

Falls back to the plain client if the custom-stub path is unavailable,
preserving the old behavior. Verified end-to-end: after this change a
single sync_turn() auto-registers chat_memory-<team>-<agent> in the
metadata store and the asset shows up in the panel bootstrap API.
@TreyDong
TreyDong marked this pull request as ready for review August 10, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant