-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
agent engine[Component] This issue is related to Agent Engine deployment[Component] This issue is related to Agent Engine deployment
Description
Describe the bug
When using the GlobalInstructionPlugin
with a Runner
, an AttributeError
is raised during the before_model_callback
. The error message, 'CallbackContext' object has no attribute 'invocation_context'
, indicates that the plugin is trying to access an attribute that does not exist on the context object provided by the runner's execution flow.
To Reproduce
Steps to reproduce the behavior:
- Initialize a
Runner
and includeGlobalInstructionPlugin
in theplugins
list. - Call the
runner.run_async()
method to start an agent execution. - The following error occurs.
Code:
# Simplified reproduction code based on provided snippets
from google.adk.runners import Runner
from google.adk.plugins import GlobalInstructionPlugin
# ... other necessary imports for agent, services, etc.
async def get_runner_async():
"""Returns a runner configured with the GlobalInstructionPlugin."""
# Assume root_agent and services are defined elsewhere
root_agent = ...
artifact_service = ...
session_service = ...
memory_service = ...
runner = Runner(
app_name="my_app",
agent=root_agent,
artifact_service=artifact_service,
session_service=session_service,
memory_service=memory_service,
plugins=[
GlobalInstructionPlugin(
global_instruction="This is a global instruction."
)
]
)
return runner
async def main():
"""Main execution function to demonstrate the bug."""
runner = await get_runner_async()
# The error occurs when run_async is called and the plugin's callback is triggered
async for event in runner.run_async(
user_id="test_user",
session_id="test_session",
new_message="Hello, agent!",
):
print(event)
# To run:
# import asyncio
# asyncio.run(main())
Metadata
Metadata
Assignees
Labels
agent engine[Component] This issue is related to Agent Engine deployment[Component] This issue is related to Agent Engine deployment