MCPcopy Create free account
hub / github.com/google/adk-python / process_llm_agent_output

Function process_llm_agent_output

src/google/adk/workflow/_llm_agent_wrapper.py:253–281  ·  view source on GitHub ↗

Processes the output of LlmAgent run as a node.

(agent: Any, ctx: Context, event: Event)

Source from the content-addressed store, hash-verified

251
252
253def process_llm_agent_output(agent: Any, ctx: Context, event: Event) -> None:
254 """Processes the output of LlmAgent run as a node."""
255 if (
256 event.get_function_calls()
257 or event.partial
258 or not event.content
259 or event.content.role != 'model'
260 ):
261 return
262
263 output = None
264 text = (
265 ''.join(p.text for p in event.content.parts if p.text and not p.thought)
266 if event.content.parts
267 else ''
268 )
269 if agent.output_schema:
270 if text.strip():
271 output = validate_schema(agent.output_schema, text)
272 else:
273 output = None
274 else:
275 output = text
276
277 if agent.output_key and output is not None:
278 ctx.actions.state_delta[agent.output_key] = output
279
280 event.output = output
281 event.node_info.message_as_output = True
282
283
284async def run_llm_agent_as_node(

Callers 1

run_llm_agent_as_nodeFunction · 0.85

Calls 4

validate_schemaFunction · 0.85
get_function_callsMethod · 0.80
stripMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected