Skip to content

feat(tools): add tool_context module aliasing ToolContext to Context - #945

Merged
AmaadMartin merged 3 commits into
google:mainfrom
AmaadMartin:feat/tools-tool-context-parity
Sep 25, 2026
Merged

AmaadMartin merged 3 commits into
google:mainfrom
AmaadMartin:feat/tools-tool-context-parity

Conversation

@adk-foundry-bot

@adk-foundry-bot adk-foundry-bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

This pull request will be merged automatically

Scheduled merge: 2026-09-25 21:47 UTC (about 24h from opening).

It was selected by [ADK Foundry] because the merge critic approved
the change, it is small, it touches no sensitive path, and CI is
green. No human has reviewed it.

To stop it: close this pull request, add the status/on-hold
label, or leave a review comment. Any of the three cancels the
merge; pushing a commit restarts the clock. Nothing is merged while
a question is open.

Approving does not stop it. An approval, or a comment that says
only lgtm, lets the merge run on schedule. Add any other text and
the merge stops.

Staged from fork PR #1365.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

  • Closes: N/A
  • Related: N/A

2. Or, if no issue exists, describe the change:

Problem:
Python ADK exports ToolContext and CallbackContext as aliases for the unified Context class (google.adk.tools.tool_context). TypeScript ADK provides Context, but it does not export ToolContext or CallbackContext. Developers who port Python agents and import ToolContext from @google/adk get a compile error.

Solution:
Re-export Context as ToolContext and CallbackContext in core/src/tools/tool_context.ts and from the package root. Direct class aliases allow a framework-constructed Context to satisfy a ToolContext parameter in both directions. Unlike Python, this module omits AuthHandler, AuthConfig, and AuthCredential because @google/adk already exports them at the package root.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

npx vitest run --project unit:core core/test/tools/tool_context_test.ts (6 passed).

Manual End-to-End (E2E) Tests:

Verified with a FunctionTool whose execute callback accepts a ToolContext parameter and updates stateDelta.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

adk-foundry-bot added 3 commits September 24, 2026 14:16
adk-python exposes ToolContext and CallbackContext from
google.adk.tools.tool_context, where both names bind to the unified
Context class. A TypeScript user porting a Python agent writes
import {ToolContext} from '@google/adk' and gets a compile error.

Bind both names to Context as plain re-exports, so a Context the
framework builds satisfies a ToolContext-typed parameter. Re-export the
three auth names the Python module re-exports from the same path.
adk-python documents its guides under docs/guides/<topic>/<feature>/.
adk-js had no such directory, so a reader porting a Python agent has
nowhere to learn which adk-js name matches ToolContext.

Add the guide and the index it needs. The unit test covers the sample.
The three auth re-exports could not be reached. The core package
exports map is a closed allowlist with no entry for this path, and it
publishes only dist, so no consumer can import them from here. All
three already ship from the package root.

Drop the guide tree with them. adk-js routes its documentation to
adk.dev, and declaring a docs/guides convention is a package-layout
decision, not part of this port.
@AmaadMartin AmaadMartin added the automerge: scheduled Foundry will merge this automatically; close it to stop that label Sep 24, 2026
@AmaadMartin

Copy link
Copy Markdown
Collaborator

Merging in about 6h unless someone objects. Close this PR, add status/on-hold, or comment to stop it. Approving, or commenting only lgtm, lets it merge. No human has reviewed this change.

@AmaadMartin

Copy link
Copy Markdown
Collaborator

Merging in about 1h unless someone objects. Close this PR, add status/on-hold, or comment to stop it. Approving, or commenting only lgtm, lets it merge. No human has reviewed this change.

@adk-foundry-approver adk-foundry-approver left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved automatically by ADK Foundry. No human has read this change.

This approval attests only that the change passed the gates below, all
enforced in code:

  • the merge critic read the diff and approved it (93.9% precision measured
    against 107 upstream pull requests with known maintainer outcomes)
  • ? changed lines across ? file(s), inside the 200/5 ceiling
  • no auth, credential, security, release or dependency-manifest path touched
  • required checks green, re-verified immediately before this approval
  • opened 24h ago and visible as automerge: scheduled throughout,
    with no objection from anyone

To stop this merging, close the pull request or add status/on-hold. To stop
the mechanism entirely, revoke this account's access; delivery continues and
nothing merges.

@AmaadMartin
AmaadMartin merged commit 57b6831 into google:main Sep 25, 2026
17 of 18 checks passed
@AmaadMartin AmaadMartin added automerge: merged Merged automatically by Foundry after its 24h review window expired with no objection and removed automerge: scheduled Foundry will merge this automatically; close it to stop that labels Sep 25, 2026
@kalenkevich kalenkevich mentioned this pull request Sep 25, 2026
prasanna8585 pushed a commit to prasanna8585/adk-js that referenced this pull request Nov 10, 2026
…oogle#945)

* feat(tools): add tool_context module aliasing ToolContext to Context

adk-python exposes ToolContext and CallbackContext from
google.adk.tools.tool_context, where both names bind to the unified
Context class. A TypeScript user porting a Python agent writes
import {ToolContext} from '@google/adk' and gets a compile error.

Bind both names to Context as plain re-exports, so a Context the
framework builds satisfies a ToolContext-typed parameter. Re-export the
three auth names the Python module re-exports from the same path.

* docs(tools): add the ToolContext developer guide

adk-python documents its guides under docs/guides/<topic>/<feature>/.
adk-js had no such directory, so a reader porting a Python agent has
nowhere to learn which adk-js name matches ToolContext.

Add the guide and the index it needs. The unit test covers the sample.

* refactor(tools): keep only the reachable part of the tool_context port

The three auth re-exports could not be reached. The core package
exports map is a closed allowlist with no entry for this path, and it
publishes only dist, so no consumer can import them from here. All
three already ship from the package root.

Drop the guide tree with them. adk-js routes its documentation to
adk.dev, and declaring a docs/guides convention is a package-layout
decision, not part of this port.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge: merged Merged automatically by Foundry after its 24h review window expired with no objection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants