-
Notifications
You must be signed in to change notification settings - Fork 314
feat: Add support for agent invoke with no input, or Message input #653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
with this PR, what's the desired state when calling with |
@@ -597,6 +624,34 @@ async def _execute_event_loop_cycle(self, invocation_state: dict[str, Any]) -> A | |||
async for event in events: | |||
yield event | |||
|
|||
def _convert_prompt_to_messages(self, prompt: str | list[ContentBlock] | Messages | None) -> Messages: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your thoughts on turning str | list[ContentBlock] | Messages | None
into a type alias? Seems like we're copying it around and it might be helpful to have some Prompt (don't over index on the name) type
@@ -408,7 +408,7 @@ def end_event_loop_cycle_span( | |||
|
|||
def start_agent_span( | |||
self, | |||
message: Message, | |||
messages: Messages, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlikely to be breaking anyone because of
def get_tracer() -> Tracer:
"""Get or create the global tracer.
Returns:
The global tracer instance.
"""
global _tracer_instance
if not _tracer_instance:
_tracer_instance = Tracer()
return _tracer_instance
?
Description
Allow an agent to be invoked with no input, or a list of messages
This updates the agents execution to support additional invocation scenarios:
First, you can invoke an agent with just the current state of the messages array:
Additionally, you can invoke the agent with an input list of messages:
This helps enable things like "putting words in claudes mouth".
Related Issues
N/A
Documentation PR
N/A
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepare
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.