Skip to content

Dapr Agents: document response_metadata on after_llm_call hooks - #5343

Open
CasperGN wants to merge 4 commits into
dapr:v1.18from
CasperGN:docs/dapr-agents-after-llm-response-metadata
Open

CasperGN wants to merge 4 commits into
dapr:v1.18from
CasperGN:docs/dapr-agents-after-llm-response-metadata

Conversation

@CasperGN

@CasperGN CasperGN commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

Documents the response_metadata key that dapr/dapr-agents#752 added to the after_llm_call hook payload. With it, a hook can read a call's token usage without wrapping the LLM client.

Changes to developing-ai/dapr-agents/dapr-agents-hooks.md:

  • The HookContext.payload row now mentions response_metadata for after_llm_call.
  • The LLM hooks section now gives the after_llm_call signature (context plus a copy of the assistant message).
  • New "Reading response metadata" section:
    • The common keys (provider, id, model, usage) and the fields some providers add on top.
    • How usage field names differ between OpenAI-style clients and AnthropicChatClient.
    • When the key is absent: structured output, streamed calls, a before_llm_call Skip/Deny, or empty metadata.
    • An example hook that logs token usage.
    • A note on hook order: on after_llm_call only Mutate stops later hooks, so an accounting hook placed after a Mutate hook is skipped whenever that hook returns Mutate. The page's general "first non-Proceed wins" rule now says so too.
  • New row in "When to use which slot": per-call token usage.

The behaviour was checked against dapr_agents/agents/durable.py (call_llm) and dapr_agents/hooks.py on dapr-agents main.

Issue reference

Documents dapr/dapr-agents#752.

Checklist

  • Doc conventions followed (matches the page's existing tables and code style)
  • In-page anchors resolve
  • Built locally with Hugo

🤖 Generated with Claude Code

Signed-off-by: Casper Nielsen <casper@diagrid.io>
@CasperGN
CasperGN requested review from a team as code owners September 28, 2026 09:03
msfussell and others added 3 commits September 28, 2026 08:26
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Casper Nielsen <casper@diagrid.io>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Casper Nielsen <casper@diagrid.io>
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.

2 participants