feat(agent): add concurrent_invocation_mode parameter#1707
Open
feat(agent): add concurrent_invocation_mode parameter#1707
Conversation
Add a new parameter to Agent.__init__ that controls concurrent invocation behavior: - 'throw' (default): Raises ConcurrencyException if concurrent invocation is attempted, maintaining existing behavior - 'unsafe_reentrant': Skips lock acquisition entirely, allowing concurrent invocations (restores pre-locking behavior) This enables power users to re-invoke the same agent without exceptions when needed, while preserving safe defaults for typical usage. Resolves #1702
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Assessment: Approve Clean implementation that provides an escape hatch for power users who need concurrent agent invocations while maintaining safe defaults. Review Summary
Note: This PR introduces a new public API parameter. Per the API Bar Raising guidelines, moderate changes like this benefit from informal API review. Consider adding the |
zastrowm
commented
Feb 16, 2026
Address PR feedback: - Update existing exception tests to explicitly pass concurrent_invocation_mode='throw' - Remove redundant test_agent_concurrent_invocation_mode_throw_raises_exception test - Rely on test_agent_concurrent_invocation_mode_default_is_throw for default verification
zastrowm
commented
Feb 17, 2026
Address PR feedback: - Add explicit warning about unsafe_reentrant making no guarantees - Remove parenthetical about restoring pre-lock behavior - Update both type definition and Agent.__init__ docstrings for consistency
|
Thanks for the documentation update! The explicit warnings about |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Users who need to re-trigger an agent during invocation (e.g., to provide feedback out-of-band) are currently blocked by
ConcurrencyExceptionintroduced in #1453. While concurrent invocation detection is valuable for safety, power users requested an escape hatch to restore the previous behavior when they need concurrent re-invocations.Resolves #1702
Public API Changes
Agent.__init__now accepts aconcurrent_invocation_modeparameter:The parameter accepts:
"throw"(default): Maintains existing behavior - raisesConcurrencyExceptionon concurrent invocation attempts"unsafe_reentrant": Skips lock acquisition entirely, allowing concurrent invocationsThe new type
ConcurrentInvocationModeis available viastrands.types.agent.ConcurrentInvocationModefor type annotations.Use Cases
"interrupt"mode to cleanly interrupt agents with new user messages