Skip to content
Discussion options

You must be logged in to vote

Pass a function as instruction, so ADK chooses the prompt from the current session state at runtime. A switch executed while constructing the agent only sees the state at construction time.

from google.adk.agents import Agent
from google.adk.agents.readonly_context import ReadonlyContext

def choose_instruction(ctx: ReadonlyContext) -> str:
    match ctx.state.get("type_error"):
        case "syntax":
            return "Help the user diagnose and fix syntax errors."
        case "runtime":
            return "Help the user diagnose runtime errors from the traceback."
        case _:
            return "Ask for the error message and relevant code."

root_agent = Agent(
    name="error_hel…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sanketpatil06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants