Skip to content

Conversation

@martimfasantos
Copy link
Contributor

Description

This pull request adds two optional parameters - final and metadata - to the utility functions new_agent_text_message and new_agent_parts_message:

  • final (bool | None): Indicates whether the message is the final one. Useful for managing control flow in streaming agent interactions.
  • metadata (dict[str, Any] | None): Allows attaching additional information to a message, such as token counts, response time, or other relevant metrics, which is helpful for monitoring and debugging during development.

NOTE: These parameters were already documented but had not been included in the function signatures. This PR ensures that the implementation is aligned with the documentation and supports enhanced message handling for streaming agents.


@martimfasantos martimfasantos requested a review from a team as a code owner May 20, 2025 17:00
@kthota-g
Copy link
Contributor

@martimfasantos types are created based on the types defined in the spec here - https://github.com/google/A2A/blob/f99d96a24547b09667696feb06f2278dc51144ec/types/src/types.ts#L248

Currently when serving a streaming request, the SSE connection terminates when a Message type object is encountered, so final is redundant.

While Message doesn't have metadata, message.parts can have metadata associated for each part. Does it help?

@martimfasantos
Copy link
Contributor Author

@martimfasantos types are created based on the types defined in the spec here - google/A2A@f99d96a/types/src/types.ts#L248

Currently when serving a streaming request, the SSE connection terminates when a Message type object is encountered, so final is redundant.

While Message doesn't have metadata, message.parts can have metadata associated for each part. Does it help?

Got it — I’ll go ahead and remove the incorrect docstring arguments then

@martimfasantos martimfasantos force-pushed the add-final-and-metadata-new-agent-message branch from 5f1d6e9 to 754656b Compare May 21, 2025 09:03
@holtskinner holtskinner changed the title fix: Add final and metadata fields to new agent messages docs: remove final and metadata fields from docstring May 28, 2025
@holtskinner holtskinner force-pushed the add-final-and-metadata-new-agent-message branch from bbc4804 to 264f3b8 Compare May 28, 2025 18:17
@holtskinner holtskinner requested review from a team and ToddSegal as code owners May 28, 2025 18:17
@holtskinner holtskinner enabled auto-merge (squash) May 28, 2025 18:18
@holtskinner holtskinner requested a review from a team May 28, 2025 18:18
@holtskinner holtskinner merged commit 3c50ee1 into a2aproject:main May 28, 2025
6 checks passed
@martimfasantos martimfasantos deleted the add-final-and-metadata-new-agent-message branch May 29, 2025 09:34
holtskinner pushed a commit that referenced this pull request Jun 9, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.2.6](v0.2.5...v0.2.6)
(2025-06-09)


### ⚠ BREAKING CHANGES

* Add FastAPI JSONRPC Application
([#104](#104))

### Features

* Add FastAPI JSONRPC Application
([#104](#104))
([0e66e1f](0e66e1f))
* Add gRPC server and client support
([#162](#162))
([a981605](a981605))
* add reject method to task_updater
([#147](#147))
([2a6ef10](2a6ef10))
* Add timestamp to `TaskStatus` updates on `TaskUpdater`
([#140](#140))
([0c9df12](0c9df12))
* **spec:** Add an optional iconUrl field to the AgentCard 🤖
([a1025f4](a1025f4))


### Bug Fixes

* Correctly adapt starlette BaseUser to A2A User
([#133](#133))
([88d45eb](88d45eb))
* Event consumer should stop on input_required
([#167](#167))
([51c2d8a](51c2d8a))
* Fix Release Version
([#161](#161))
([011d632](011d632))
* generate StrEnum types for enums
([#134](#134))
([0c49dab](0c49dab))
* library should released as 0.2.6
([d8187e8](d8187e8))
* remove error types from enqueable events
([#138](#138))
([511992f](511992f))
* **stream:** don't block event loop in EventQueue
([#151](#151))
([efd9080](efd9080))
* **task_updater:** fix potential duplicate artifact_id from default v…
([#156](#156))
([1f0a769](1f0a769))


### Documentation

* remove final and metadata fields from docstring
([#66](#66))
([3c50ee1](3c50ee1))
* Update Links to Documentation Site
([5e7d418](5e7d418))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
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