refactor(templates): reduce strands-http-python to a barebones agent - #19
Closed
Hweinstock wants to merge 1 commit into
Closed
refactor(templates): reduce strands-http-python to a barebones agent#19Hweinstock wants to merge 1 commit into
Hweinstock wants to merge 1 commit into
Conversation
Hweinstock
force-pushed
the
feat/simplify-strands-python-template
branch
from
September 2, 2026 21:03
b287c2d to
e366e9f
Compare
Hweinstock
force-pushed
the
feat/rename-templates
branch
2 times, most recently
from
September 2, 2026 22:10
b5d6e88 to
1425fec
Compare
Hweinstock
force-pushed
the
feat/simplify-strands-python-template
branch
from
September 2, 2026 22:40
e366e9f to
2684bec
Compare
Hweinstock
force-pushed
the
feat/simplify-strands-python-template
branch
from
September 2, 2026 22:45
2684bec to
802e17b
Compare
Hweinstock
changed the base branch from
refactor
to
feat/wire-model-providers
September 2, 2026 23:35
Hweinstock
force-pushed
the
feat/simplify-strands-python-template
branch
4 times, most recently
from
September 3, 2026 02:59
f80c302 to
7e6e86c
Compare
Hweinstock
commented
Sep 3, 2026
| `model/load.py` instantiates your chosen model provider. | ||
| `model/load.py` instantiates the Bedrock model provider. | ||
|
|
||
| The agent reuses one Strands `Agent` per `session_id`, so successive invocations that share a session keep their |
Owner
Author
There was a problem hiding this comment.
you can remove this block.
| }); | ||
| }); | ||
|
|
||
| test("no scaffold shortcut renders the export-only strands template", async () => { |
Owner
Author
There was a problem hiding this comment.
delete this test, it should exist in the handlers not here.
Hweinstock
force-pushed
the
feat/simplify-strands-python-template
branch
from
September 3, 2026 03:17
7e6e86c to
d5a248c
Compare
Hweinstock
commented
Sep 3, 2026
| await expect(run(flags)).rejects.toThrow(pattern); | ||
| }); | ||
|
|
||
| test("scaffolds a strands runtime without the export-only harness template files", async () => { |
Owner
Author
There was a problem hiding this comment.
this test looks uselsss, remove it.
Hweinstock
force-pushed
the
feat/simplify-strands-python-template
branch
from
September 3, 2026 04:04
d5a248c to
4c321ec
Compare
Hweinstock
commented
Sep 3, 2026
| return LiteLLMModel( | ||
| client_args=client_args, | ||
| model_id="{{#if modelId}}{{modelId}}{{else}}bedrock/us.anthropic.claude-sonnet-4-5-20250514-v1:0{{/if}}", | ||
| params=params, |
Owner
Author
There was a problem hiding this comment.
imo templating in params here for litellm is unnecessary complexity. If a customer wants to user liteLLM I think its easier to take this default as the scaffolding and adjust from there rather than passing on command line.
Hweinstock
changed the base branch from
feat/wire-model-providers
to
refactor
September 3, 2026 15:13
Hweinstock
force-pushed
the
feat/simplify-strands-python-template
branch
from
September 3, 2026 15:13
4c321ec to
187fc5d
Compare
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.
Summary
The base leaves
agent-python-strands— the template the scaffold path (agentcore project create/add runtime) renders — rich (~715-linemain.py, plusmcp_client/,skills/,model/mantle_compat.py), carrying dozens of flags no scaffold ever sets. The harness-export template was already split out intotemplates/export-harness-python(by aws#2170).This PR makes
agent-python-strandsa barebones Strands agent:main.py→ ~130 lines: a single tool, a per-session_idin-processAgentcache, prompt extraction, and the stream entrypoint. Dropped every export-only flag (tools, execution limits, truncation, gateways, remote MCP, mounts, config bundle, payments, Mantle).mcp_client/,skills/,model/mantle_compat.pyfrom the scaffold template (they live only inexport-harness-pythonnow).model/load.pybranches on Bedrock/Anthropic/OpenAI/Gemini/LiteLLM, andpyproject.tomlpulls provider SDKs viastrands-agents[<provider>]extras. With feat(runtime): support Anthropic, OpenAI, and Gemini model providers #20's provider wiring onrefactor, the barebones template renders correct clients + AgentCore Identity wiring for non-Bedrock providers.runtime.tsto the keys the barebones template uses.Net: +80 / −1170 lines across 11 files.
export harnessis untouched (it rendersexport-harness-python, provided by aws#2170).No-memory session retention
An agent without memory reuses one
Agentpersession_id(in-process LRU cache), so successive invokes on the same session keep their conversation history within a live process — the same behavior the previous template had. This is best-effort (the cache resets on cold start / isn't shared across instances); for durable, cross-instance history, add memory (the session manager), preserved here.Spec
Verification
Re-run after the aws#2170 rebase, against dev account
440744214761/us-east-1, using the compiled binary (bun run compile).Unit tests / build
bun run typecheck→ clean;oxlint/prettier --check→ cleanbun test→ 2798 pass, 0 fail (incl. feat(runtime): support Anthropic, OpenAI, and Gemini model providers #20's non-Bedrock provider tests; snapshot updated: scaffold no longer emitsmcp_client/,skills/,model/mantle_compat.py)project create --model-provider open_ai(andgemini,anthropic) renders valid Python — e.g. OpenAI →OpenAIModel(model_id="gpt-4.1")with@requires_api_keyIdentity wiring; deps resolve tostrands-agents[openai]/[gemini]/[anthropic]/ plain for Bedrock. Allpy_compile-clean.Scaffold (both build types × all 3 memory options)
One project, 6 runtimes: CodeZip + Container, each with memory =
none | shortTerm | longAndShortTerm. All generated Python compiles.Local dev (
agentcore project dev --mode headless)"21 + 21? Use your tool."→ "The result of 21 + 21 is 42."; same-session codeword → "The codeword you gave me is ORANGE."Deployed on AWS (
agentcore project deploy+project invoke runtime)All 6 runtimes invoked via the AWS
InvokeAgentRuntimeAPI; all retained context within a warm session ("Your name is Bob and your favorite fruit is mango.").Durability contrast (new session id, same
--user-id):How to reproduce
Teardown
aws cloudformation delete-stack --stack-name AgentCore-demo-default --region us-east-1