Skip to content

feat(hooks): include text and message in AGENT_COMPLETE event#60

Merged
galuszkm merged 2 commits into
mainfrom
copilot/feature-include-last-assistant-message
Jun 21, 2026
Merged

feat(hooks): include text and message in AGENT_COMPLETE event#60
galuszkm merged 2 commits into
mainfrom
copilot/feature-include-last-assistant-message

Conversation

Copilot AI commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

AGENT_COMPLETE events carried usage metrics but not the assistant's final output, forcing consumers to separately reconstruct it. text and message are now always present in the payload — uniform contract, no optional-key guards needed.

Changes

src/strands_compose/hooks/event_publisher.py

  • AGENT_COMPLETE data now always includes:
    • textstr(result) (flat string: handles text, citations, structured output) or "" when no result
    • messageresult.message (full Message TypedDict: role, content blocks, metadata) or {} when no result
# AGENT_COMPLETE event data shape
{
    "type": "agent",
    "usage": {"input_tokens": ..., "output_tokens": ..., "total_tokens": ...},
    "text": "Final assistant response as plain string",
    "message": {
        "role": "assistant",
        "content": [...],   # text, toolUse, reasoningContent, citationsContent
        "metadata": {...},  # per-turn usage + metrics
    },
}

tests/unit/hooks/test_event_publisher.py

  • Updated existing usage test to explicitly set result=None
  • Added test: text/message populated correctly when result is present
  • Added test: text=""/message={} defaults when result is None

Copilot AI changed the title [WIP] Add last assistant message to AGENT_COMPLETE event feat(hooks): include text and message in AGENT_COMPLETE event Jun 21, 2026
Copilot AI requested a review from galuszkm June 21, 2026 16:04

@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

@galuszkm galuszkm marked this pull request as ready for review June 21, 2026 16:05
@galuszkm galuszkm linked an issue Jun 21, 2026 that may be closed by this pull request
@galuszkm galuszkm merged commit ee9d731 into main Jun 21, 2026
8 checks passed
@galuszkm galuszkm deleted the copilot/feature-include-last-assistant-message branch June 21, 2026 16:07
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.

[FEATURE] Include last assistant message in AGENT_COMPLETE event

2 participants