Skip to content

Conversation

@PratikMahajan
Copy link
Contributor

Description

This PR enhances our A2A framework by adding HTTP headers to the ServerCallContext, making them accessible via context.state['headers']. The call context is a key component of our request-handling system, designed to provide handlers with request-specific information—like user details and additional state—in a structured, modular way. This abstraction keeps our handlers clean and decoupled from the raw HTTP request.

Why Add Headers to the Context?

  • Essential Metadata: HTTP headers carry critical information, such as authentication tokens, content types, and custom parameters, that handlers often need to process requests correctly. Including headers in the context ensures this data is easily accessible.
  • Architectural Consistency: We already use the call context to pass request-specific data (e.g., state['auth']). Adding headers follows this established pattern, keeping our design cohesive.
  • Better Developer Experience: Without this change, accessing headers in handlers requires extra effort, like refactoring or passing the full request object. With headers in context.state['headers'], developers can work more efficiently and with fewer errors.

Addressing Concerns:

  • Performance: Headers are small, and their inclusion in the per-request context has a negligible performance impact.
  • Security: Headers may include sensitive data (e.g., tokens), but the call context already handles similar information securely. Handlers should follow existing best practices for data handling.

This change makes our framework more intuitive and developer-friendly. I encourage the team to merge this PR to improve handler efficiency and maintain a consistent, modular architecture.

  • Follow the CONTRIBUTING Guide.
  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.
    • Important Prefixes for release-please:
      • fix: which represents bug fixes, and correlates to a SemVer patch.
      • feat: represents a new feature, and correlates to a SemVer minor.
      • feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.
  • Ensure the tests and linter pass (Run nox -s format from the repository root to format)
  • Appropriate docs were updated (if necessary)

Include HTTP headers in the ServerCallContext to provide
handlers with easy access to critical request metadata.

This change maintains consistency with the existing design
pattern of using the call context for request-specific data
and simplifies handler implementation by making headers
readily available via `context.state['headers']`.
@PratikMahajan PratikMahajan requested a review from a team as a code owner June 11, 2025 19:48
Copy link
Contributor

@mikeas1 mikeas1 left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution!

@mikeas1 mikeas1 merged commit d5e5f5f into a2aproject:main Jun 11, 2025
6 checks passed
holtskinner pushed a commit that referenced this pull request Jun 12, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.2.8](v0.2.7...v0.2.8)
(2025-06-12)


### Features

* Add HTTP Headers to ServerCallContext for Improved Handler Access
([#182](#182))
([d5e5f5f](d5e5f5f))
* Update A2A types from specification 🤖
([#191](#191))
([174230b](174230b))


### Bug Fixes

* Add `protobuf==6.31.1` to dependencies
([#189](#189))
([ae1c31c](ae1c31c)),
closes [#185](#185)

---
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.

2 participants