Skip to content

Conversation

Unshure
Copy link
Member

@Unshure Unshure commented Aug 11, 2025

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:

agent = Agent(messages=[{"role":"user", "content":[{"text":"Hello!"}]}])
agent()

Additionally, you can invoke the agent with an input list of messages:

agent = Agent()
agent([
  {"role":"user", "content":[{"text":"Hello!"}]},
  {"role":"assistant", "content":[{"text":"How are"}]},
])

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

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mkmeral
Copy link
Contributor

mkmeral commented Aug 12, 2025

with this PR, what's the desired state when calling with None?

@Unshure
Copy link
Member Author

Unshure commented Aug 25, 2025

with this PR, what's the desired state when calling with None?

You can check the integration tests. Basically, we invoke the model with the messages currently in the agents messages array.

@Unshure Unshure merged commit dbe0fea into strands-agents:main Aug 25, 2025
12 checks passed
@Unshure Unshure deleted the agent-invoke-none-or-message branch August 25, 2025 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants