Skip to content

feat(delegate): wire agent connections through Agent.as_tool - #80

Merged
galuszkm merged 2 commits into
mainfrom
feat/mg/delegate
Aug 15, 2026
Merged

feat(delegate): wire agent connections through Agent.as_tool#80
galuszkm merged 2 commits into
mainfrom
feat/mg/delegate

Conversation

@galuszkm

Copy link
Copy Markdown
Member

Description

Delegate connections to an agent now go through strands.Agent.as_tool() instead of a hand-rolled @tool wrapper. The wrapper's biggest problem was interrupts: it turned a sub-agent's interrupt into an empty success, so a pending approval looked granted to the coordinator. Agent.as_tool() propagates the interrupt properly and lets it be answered and resumed.

That native adapter also owns preserve_context, so it's now exposed as connections[].preserve_context on a delegate connection. Setting it false resets the delegate to its construction-time baseline before every call — the only way to bound a stateless delegate's history in a long-lived session, since orchestrations share one live agent object across calls. It's rejected for a connection to a nested orchestration (no baseline to reset to) and for an agent carrying a session manager (persisting and wiping every call are contradictory) — both left to surface as-is rather than reimplemented, so the messages stay accurate if upstream's rules ever change.

A Swarm/Graph target has no as_tool() upstream, so it keeps a single hand-rolled wrapper (multiagent_as_tool, replacing node_as_tool/node_as_async_tool), which now also reports an interrupt raised inside the orchestration as a tool error instead of silently succeeding.

Also in this PR:

  • extract_block_text reads citationsContent blocks, so a cited answer's text now crosses the delegation boundary instead of being dropped
  • the converters package (StreamConverter, OpenAIStreamConverter, RawStreamConverter) is removed — framing StreamEvents into a wire format is a transport-layer concern, not something this library should own
  • strands-agents floor bumped to 1.52.0 for the as_tool() behaviour this relies on

Related Issues

N/A

Type of Change

  • Breaking change

YAML / API Impact

Config schema:

  • new field connections[].preserve_context: bool (default true) on delegate connections

Public Python API (strands_compose):

  • removed: node_as_tool, node_as_async_tool
  • added: multiagent_as_tool (replaces both for Swarm/Graph targets; an Agent target now goes through strands.Agent.as_tool() directly)
  • removed: strands_compose.converters (StreamConverter, OpenAIStreamConverter, RawStreamConverter)

Not backwards-compatible: any code importing node_as_tool, node_as_async_tool, or strands_compose.converters breaks. A delegate tool's result now carries text blocks only (previously also image/document/json, which a model cannot itself emit into its own final message, so this had no live use). Requires strands-agents>=1.52.0,<2.0.0.

Testing

  • I ran uv run just check (lint + type check)
  • I ran uv run just test for overall testing
  • I added or updated tests that prove my fix is effective or my feature works
  • I verified existing examples in examples/ still work

Checklist

  • I have read the CONTRIBUTING document
  • I have updated the documentation accordingly
  • 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.

- delegate to an agent through the strands-native adapter
- add connections[].preserve_context, so a delegate can start every call from a clean baseline
- reject preserve_context: false for a nested orchestration
- keep one wrapper - multiagent_as_tool
- carry text from citationsContent blocks across the delegation boundary
- drop the converters package
@galuszkm
galuszkm merged commit 237c838 into main Aug 15, 2026
9 checks passed
@galuszkm
galuszkm deleted the feat/mg/delegate branch August 15, 2026 15:56
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.

1 participant