Skip to content

feat(export): build exported harness agents with Strands Harness - #2486

Open
amhegazy-mp4 wants to merge 1 commit into
aws:refactorfrom
amhegazy-mp4:feat/strands-harness-export-refactor
Open

amhegazy-mp4 wants to merge 1 commit into
aws:refactorfrom
amhegazy-mp4:feat/strands-harness-export-refactor

Conversation

@amhegazy-mp4

@amhegazy-mp4 amhegazy-mp4 commented Sep 30, 2026 •

Copy link
Copy Markdown

Description

agentcore export harness now builds the exported agent the way the harness runtime does: strands_harness.create_harness() with its defaults turned off and each capability passed explicitly, instead of a bare Strands Agent with hand-written tools. The construction lives in a new generated module, harness_runtime.py.

  • Built-in tools. The SDK's sandbox-routed shell, the Strands Harness read/write/edit, and web_fetch in markdown mode, each gated by allowedTools (file_operations still grants read/write/edit).
  • Plugins. todo_write (todos) and retrieve_offloaded_content (a context offloader that keeps large tool results on disk per session and never evicts them).
  • Subagent. A subagent tool delegates to a generalist child that can use the agent's built-in and MCP tools, gets only the plugins it selects, has no session manager, and cannot delegate further.
  • Shared limits. One budget, passed in the invocation state, covers the agent and its subagents. maxIterations/maxTokens end the invocation with max_iterations_exceeded / max_output_tokens_exceeded. With the subagent tool enabled, usage is reported once per invocation including subagents; otherwise per model call.
  • MCP. Tools are prefixed with their server name (<server>_<tool>), as in the harness, so they cannot collide with the built-ins.
  • Defaults when unset. The Strands Harness contract prompt and summarization truncation (summary_ratio 0.3, preserve_recent_messages 10). Bedrock Converse models cache the system prompt and tools unless the model parameters already place a cache point.
  • Dependencies. Pins strands-agents ~= 1.57.1 and strands-harness == 0.1.2.

Known differences from the harness: shell and file tools run on the runtime host rather than in a container sandbox, offloaded results have no per-session size cap, and tool names are not shortened to fit Bedrock's 64-character limit.

Related Issue

Closes #2485

Documentation PR

Not applicable.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

  • I ran bun test
  • I ran the relevant end-to-end tests with bun run test:e2e, or explained why they are not applicable: there are no export end-to-end tests. Instead I rendered 14 harness shapes (all built-ins with limits, none, subagent only, each plugin alone, inline functions with and without MCP and a timeout, S3 skills, memory, no truncation); each passes pyflakes and py_compile and builds an agent against the pinned packages. I also ran exports against Bedrock with a local MCP server: @mcp/tool filtering, subagent delegation with context offloading, the shared iteration limit, a timeout cancelling a running subagent, and an inline function handoff.
  • I ran bun run typecheck
  • I ran bun run lint:check
  • I ran bun run format:check
  • I ran bun run build
  • If I modified src/assets/, I updated affected snapshots with bun test <test-file> --update-snapshots and committed them (no snapshots changed)

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.

@github-actions github-actions Bot added the size/xl PR size: XL label Sep 30, 2026
@codecov-commenter

codecov-commenter commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.40%. Comparing base (04b45c3) to head (4c46a27).

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #2486   +/-   ##
=========================================
  Coverage     97.39%   97.40%           
=========================================
  Files           642      642           
  Lines         46807    46854   +47     
=========================================
+ Hits          45590    45638   +48     
+ Misses         1217     1216    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Exported agents now reproduce how the harness runtime builds agents:
strands_harness.create_harness() with its defaults off and each capability
passed explicitly, instead of a bare Strands Agent with hand-written tools.
The construction lives in a generated harness_runtime.py module.

- Built-in tools: sandbox-routed shell, Strands Harness read/write/edit,
  and markdown web_fetch, each gated by allowedTools.
- Plugins: todos (todo_write) and a context offloader
  (retrieve_offloaded_content) that never evicts entries.
- Subagent tool: a generalist child that can use the parent's built-in
  and MCP tools and gets only the plugins it selects.
- One invocation budget, passed in the invocation state, is shared by the
  agent and its subagents; a limit ends the invocation with
  max_iterations_exceeded or max_output_tokens_exceeded. With the subagent
  tool enabled, usage is reported once per invocation, including the
  subagents'; otherwise per model call.
- MCP tools are prefixed with their server name so they cannot collide
  with the built-ins.
- Defaults when unset: the Strands Harness contract prompt and
  summarization truncation; Bedrock Converse models cache prompts and tools
  unless the model parameters already place a cache point.
- Pins strands-agents ~= 1.57.1 and strands-harness == 0.1.2.
@amhegazy-mp4
amhegazy-mp4 force-pushed the feat/strands-harness-export-refactor branch from 6b26693 to 4c46a27 Compare September 30, 2026 21:18
@github-actions github-actions Bot added size/l PR size: L and removed size/xl PR size: XL size/l PR size: L labels Sep 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants