You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit clarifies the behavior of the `temp:` namespace in the documentation.
The following changes were made:
- Updated `docs/sessions/state.md` to provide a more detailed explanation of the `temp:` namespace.
- Updated `docs/context/index.md` to improve the clarity of an example related to passing data between tools.
- Updated `docs/runtime/index.md` to add a note about the scope of `temp:` variables.
- Updated `docs/agents/multi-agents.md` and `docs/agents/workflow-agents/sequential-agents.md` to clarify how the `temp:` namespace is propagated to sub-agents.
- Updated `docs/tools/function-tools.md` to explain how to use the `temp:` namespace to pass data between tool calls.
fixes#160
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Joe Fernandez <[email protected]>
When a parent agent invokes a sub-agent, it passes the same `InvocationContext`. This means they share the same temporary (`temp:`) state, which is ideal for passing data that is only relevant for the current turn.
This ensures the code is written, *then* reviewed, and *finally* refactored, in a strict, dependable order. **The output from each sub-agent is passed to the next by storing them in state via [Output Key](../llm-agents.md#structuring-data-input_schema-output_schema-output_key)**.
39
39
40
+
!!! note "Shared Invocation Context"
41
+
The `SequentialAgent` passes the same `InvocationContext` to each of its sub-agents. This means they all share the same session state, including the temporary (`temp:`) namespace, making it easy to pass data between steps within a single turn.
Copy file name to clipboardExpand all lines: docs/context/index.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -447,12 +447,13 @@ You'll frequently need to read information stored within the context.
447
447
}
448
448
```
449
449
450
-
### Managing Session State
450
+
### Managing State
451
451
452
452
State is crucial for memory and data flow. When you modify state using `CallbackContext` or `ToolContext`, the changes are automatically tracked and persisted by the framework.
453
453
454
454
***How it Works:** Writing to `callback_context.state['my_key'] = my_value` or `tool_context.state['my_key'] = my_value` adds this change to the `EventActions.state_delta` associated with the current step's event. The `SessionService` then applies these deltas when persisting the event.
Copy file name to clipboardExpand all lines: docs/runtime/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -260,7 +260,7 @@ Several components work together within the ADK Runtime to execute an agent invo
260
260
6.### `Invocation`
261
261
262
262
***Role:** A conceptual term representing everything that happens in response to a *single* user query, from the moment the `Runner` receives it until the agent logic finishes yielding events for that query.
263
-
***Function:** An invocation might involve multiple agent runs (if using agent transfer or `AgentTool`), multiple LLM calls, tool executions, and callback executions, all tied together by a single `invocation_id` within the `InvocationContext`.
263
+
***Function:** An invocation might involve multiple agent runs (if using agent transfer or `AgentTool`), multiple LLM calls, tool executions, and callback executions, all tied together by a single `invocation_id` within the `InvocationContext`. State variables prefixed with `temp:` are strictly scoped to a single invocation and discarded afterwards.
264
264
265
265
These players interact continuously through the Event Loop to process a user's request.
***Scope:** Specific to the *current* session processing turn.
64
-
***Persistence:****Never Persistent.** Guaranteed to be discarded, even with persistent services.
65
-
***Use Cases:** Intermediate results needed only immediately, data you explicitly don't want stored.
63
+
***Scope:** Specific to the current **invocation** (the entire process from an agent receiving user input to generating the final output for that input).
64
+
***Persistence:****Not Persistent.** Discarded after the invocation completes and does not carry over to the next one.
65
+
***Use Cases:** Storing intermediate calculations, flags, or data passed between tool calls within a single invocation.
66
+
***When Not to Use:** For information that must persist across different invocations, such as user preferences, conversation history summaries, or accumulated data.
When a parent agent calls a sub-agent (e.g., using `SequentialAgent` or `ParallelAgent`), it passes its `InvocationContext` to the sub-agent. This means the entire chain of agent calls shares the same invocation ID and, therefore, the same `temp:` state.
71
+
68
72
**How the Agent Sees It:** Your agent code interacts with the *combined* state through the single `session.state` collection (dict/ Map). The `SessionService` handles fetching/merging state from the correct underlying storage based on prefixes.
Copy file name to clipboardExpand all lines: docs/tools/function-tools.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,6 +104,15 @@ Strive to make your return values as descriptive as possible. *For example,* ins
104
104
105
105
The docstring of your function serves as the tool's **description** and is sent to the LLM. Therefore, a well-written and comprehensive docstring is crucial for the LLM to understand how to use the tool effectively. Clearly explain the purpose of the function, the meaning of its parameters, and the expected return values.
106
106
107
+
### Passing Data Between Tools
108
+
109
+
When an agent calls multiple tools in a sequence, you might need to pass data from one tool to another. The recommended way to do this is by using the `temp:` prefix in the session state.
110
+
111
+
A tool can write data to a `temp:` variable, and a subsequent tool can read it. This data is only available for the current invocation and is discarded afterwards.
112
+
113
+
!!! note "Shared Invocation Context"
114
+
All tool calls within a single agent turn share the same `InvocationContext`. This means they also share the same temporary (`temp:`) state, which is how data can be passed between them.
0 commit comments