Skip to content

Update ADK doc according to issue #1438 - 17#1448

Open
adk-bot wants to merge 1 commit intomainfrom
agent-changes-20260316-014857
Open

Update ADK doc according to issue #1438 - 17#1448
adk-bot wants to merge 1 commit intomainfrom
agent-changes-20260316-014857

Conversation

@adk-bot
Copy link
Copy Markdown
Collaborator

@adk-bot adk-bot commented Mar 16, 2026

17. Document context injection and context_param_name for FunctionTool

Doc file: docs/tools-custom/function-tools.md

Current state:

Return Type

The preferred return type for a Function Tool is a dictionary in Python, a Map in Java, or an object in TypeScript. This allows you to structure the response with key-value pairs, providing context and clarity to the LLM. If your function returns a type other than a dictionary, the framework automatically wraps it into a dictionary with a single key named "result".

Proposed Change:

Return Type

The preferred return type for a Function Tool is a dictionary in Python, a Map in Java, or an object in TypeScript. This allows you to structure the response with key-value pairs, providing context and clarity to the LLM. If your function returns a type other than a dictionary, the framework automatically wraps it into a dictionary with a single key named "result".

Context Injection

If your function needs access to the agent's context (e.g., to read/write state, access authentication, or use artifacts), add a parameter named tool_context with type ToolContext to your function signature. The ADK will automatically inject the context when calling your function.

def my_tool(arg1: str, tool_context: ToolContext):
    # ... use tool_context ...

You can customize the parameter name used for injection by passing context_param_name to the FunctionTool constructor.

Reasoning:
The FunctionTool now supports customizing the context parameter name via context_param_name. Also, explicitly documenting context injection clarifies how to access ToolContext in custom functions.

Reference: src/google/adk/tools/function_tool.py

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 16, 2026

Deploy Preview for adk-docs-preview ready!

Name Link
🔨 Latest commit 16b077d
🔍 Latest deploy log https://app.netlify.com/projects/adk-docs-preview/deploys/69b7618e24ffb6000833edb7
😎 Deploy Preview https://deploy-preview-1448--adk-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants