MCPcopy Index your code
hub / github.com/google/adk-python / Context

Class Context

src/google/adk/agents/context.py:118–925  ·  view source on GitHub ↗

The context within an agent run. When used in a workflow, additional fields under the ``Workflow-specific fields`` section are available.

Source from the content-addressed store, hash-verified

116
117
118class Context(ReadonlyContext):
119 """The context within an agent run.
120
121 When used in a workflow, additional fields under the ``Workflow-specific
122 fields`` section are available.
123 """
124
125 def __init__(
126 self,
127 invocation_context: InvocationContext,
128 *,
129 # Core State & Actions
130 event_actions: EventActions | None = None,
131 # Tool Execution
132 function_call_id: str | None = None,
133 tool_confirmation: ToolConfirmation | None = None,
134 # Workflow Execution
135 parent_ctx: Context | None = None,
136 node: BaseNode | None = None,
137 node_path: str | None = None,
138 run_id: str = '',
139 resume_inputs: dict[str, Any] | None = None,
140 attempt_count: int = 1,
141 use_as_output: bool = False,
142 ) -> None:
143 """Initializes the Context.
144
145 Args:
146 invocation_context: The invocation context.
147 event_actions: The event actions for state and artifact deltas.
148 function_call_id: The function call id of the current tool call. Required
149 for tool-specific methods like request_credential and
150 request_confirmation.
151 tool_confirmation: The tool confirmation of the current tool call.
152 parent_ctx: The parent node's Context.
153 node: The current node.
154 node_path: The path of the current node in the workflow graph. If not
155 provided, it will be derived from parent_ctx and node.
156 run_id: The execution ID of the current node.
157 resume_inputs: Inputs for resuming node, keyed by interrupt id.
158 attempt_count: Number of times this node has been attempted.
159 use_as_output: If True, this node's output also represents the parent
160 node's output.
161 """
162 super().__init__(invocation_context)
163
164 self._parent_ctx = parent_ctx
165 self._node = node
166
167 from ..events.event_actions import EventActions
168 from ..sessions.state import State
169 from ..telemetry.node_tracing import TelemetryContext
170
171 # Core State & Actions, Event & Telemetry
172 self._event_actions = event_actions or EventActions()
173
174 computed_state_schema = None
175 if node and node.state_schema:

Calls

no outgoing calls