Replies: 1 comment
|
Pass a function as 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_helper",
model="gemini-2.5-flash",
instruction=choose_instruction,
)Make sure the tool or callback that determines the error writes If you only need to insert a value into a fixed prompt, a string such as |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
How to use dynamic prompt in ADK? I tried creating a variable
type_errorin state that will change depends on user's input, then use a switch case to set the instructions for agents, but it did not work. I think it is because the agents are initialized once at the beginning of the app - when the state andtype_errorstill NoneAll reactions