Skip to content

Include model_id and provider in AGENT_COMPLETE events#71

Merged
galuszkm merged 2 commits into
mainfrom
copilot/study-agent-complete-event
Jul 18, 2026
Merged

Include model_id and provider in AGENT_COMPLETE events#71
galuszkm merged 2 commits into
mainfrom
copilot/study-agent-complete-event

Conversation

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Consumers of EventPublisher had to correlate AGENT_COMPLETE token usage against the SESSION_START manifest by agent name just to look up which model produced the usage — extra state to track for a simple cost calculation.

  • Shared descriptor extraction: renamed manifest._model_descriptor to public manifest.model_descriptor(agent), no logic change, now reusable outside manifest building.
  • Richer AGENT_COMPLETE payload: EventPublisher._on_complete now calls model_descriptor(event.agent) and adds model_id and provider to the event data, alongside the existing usage, text, and message.
  • Docs: updated the event reference table to list the new fields.
# Before: had to join AGENT_COMPLETE.agent_name against the manifest to find model_id
# After:
async for event in ...:
    if event.type == EventType.AGENT_COMPLETE:
        cost = price_table[event.data["model_id"]].compute(event.data["usage"])

@galuszkm galuszkm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot implement my comments

"output_tokens": usage.get("outputTokens", 0),
"total_tokens": usage.get("totalTokens", 0),
},
"model_id": model.model_id,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to have it collected as “model”:{“model_id”:…, “provider”: …}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b8f8e0b — payload is now "model": {"model_id": ..., "provider": ...}.

@galuszkm galuszkm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the AGENT_COMPLETE event payload so consumers can attribute token usage to a specific model/provider without having to join against the SESSION_START manifest, which simplifies downstream cost calculation.

Changes:

  • Exposes model descriptor extraction as manifest.model_descriptor(agent) (renamed from a private helper) for reuse outside manifest building.
  • Enriches EventPublisher’s AGENT_COMPLETE payload with model identification data derived from the agent (model_id, provider).
  • Adds a regression test and updates the docs event reference table to reflect the new payload fields.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/runtime/test_event_stream.py Adds coverage asserting AGENT_COMPLETE includes model identity info.
src/strands_compose/manifest.py Makes model descriptor extraction a public helper used by multiple components.
src/strands_compose/hooks/event_publisher.py Adds model identity information to AGENT_COMPLETE event data.
docs/configuration/Chapter_15.md Documents the updated AGENT_COMPLETE payload fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/strands_compose/hooks/event_publisher.py
@galuszkm
galuszkm merged commit 0b19672 into main Jul 18, 2026
8 checks passed
@galuszkm
galuszkm deleted the copilot/study-agent-complete-event branch July 18, 2026 18:26
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.

3 participants