Skip to content

Context variable not found: initial_topic #1062

@ACodingfreak

Description

@ACodingfreak

Hi All,

The loop_agent example which is available in below link is throwing error "'Context variable not found: initial_topic.'" on execution from adk web.

https://google.github.io/adk-docs/agents/workflow-agents/loop-agents/

I am wondering if this is because we are trying to access initial_topic variable in sub_agent under root_agent. I tried something as shown below and it seems to work. I am wondering if there is a better way to fix the same.

state_initializer_agent = LlmAgent(
    name="StateInitializer",
    model=Gemini(
        model=GEMINI_MODEL,  
        retry_options=retry_config
    ),
    instruction="Output the user's request verbatim.",
    description="Captures the initial user topic and saves it to the session state.",
    output_key=STATE_INITIAL_TOPIC  # <--- This is the key that was missing!
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions