Replies: 1 comment
-
| 
         Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: While the  Hello! Thanks for your question. Your observation is correct: the  For the granular context control you're looking for, ADK provides a more explicit and powerful mechanism: the session state. Think of  Here is the recommended pattern for providing specific, custom context to an agent: 1. Store Information in  2. Inject State into another Agent's Instructions: Here's a conceptual example of how this works in a multi-agent setup: from google.adk.agents import LlmAgent, SequentialAgent
# This agent identifies the key topic and saves it to the state.
topic_extractor_agent = LlmAgent(
    name="TopicExtractor",
    instruction="Identify the main topic from the user's message and output only that topic.",
    output_key="topic"  # The result will be saved to session.state['topic']
)
# This agent receives the specific 'topic' as context in its instructions.
deep_dive_agent = LlmAgent(
    name="DeepDive",
    # The {topic} placeholder is filled from session.state['topic'] before being sent to the LLM.
    instruction="Provide a detailed explanation of the following topic: {topic}"
)
# A SequentialAgent orchestrates the flow, ensuring the state is passed along.
pipeline = SequentialAgent(
    name="MyPipeline",
    sub_agents=[topic_extractor_agent, deep_dive_agent]
)In this example, the  You can also read from and write to  This state-passing mechanism is central to building sophisticated multi-turn and multi-agent workflows in ADK. [5, 7] [1] https://google.github.io/adk-docs/agents/llm-agents/  | 
  
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, when defining an agent, the available context options are limited to
include_contents: literal ['default', 'none']. This design restricts agents to either accessing the entirety of the session's context or having no context at all.However, in real-world development, agents often require more granular control over the context they receive. For instance, an agent might only need its own specific context within the broader session. The ability to define and utilize custom context is crucial for implementing advanced features like multi-turn dialogues, where an agent needs to recall specific information from its previous interactions without being overwhelmed by unrelated data from the entire session.
Therefore, optimizing the context handling mechanism to allow for custom context definitions is a critical improvement. This would empower developers to build more sophisticated and efficient multi-turn dialogue agents.
Beta Was this translation helpful? Give feedback.
All reactions