feat(templates): add the agent-python-langchain template - #2230
Conversation
…et table and resolver Adds the langchain framework value, the CodeZip Bedrock-only preset, and a resolver keyed langchain/Python/HTTP that renders the template with name as its only variable. Recording the new manifest snapshot also pruned the obsolete Strands AG-UI snapshot left behind when its test was removed in #2214.
…review Drops the copied log line, reads content_blocks once per chunk, inlines the render context, replaces the duplicated flag-path assertions with the one check the snapshot cannot make, and registers the template in the add-runtime memory table.
parseAgentEvent knew the Strands ConverseStream shape, {text}, {error}, and
bare strings, so a LangChain agent streaming {node, content: [blocks]}
showed an empty response in the inspector chat. Text blocks are now joined
into a text frame and tool-call-only chunks are dropped.
…rk and drop the build suffixes The recommended Strands template keeps the initial focus wherever it sits, so the wizard tests now step up from it instead of counting down.
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
Nice, tight addition. I ran through the diff and spot-checked the runtime behavior:
- Verified experimentally with
langgraph~=1.2.11/langchain~=1.4.0thatagent.astream(..., stream_mode="messages", version="v2")yields{"type":"messages","data":(AIMessageChunk, metadata)}dicts, so theevent["data"]destructure inmain.pyis correct. Withoutversion="v2"it would yield bare tuples — worth calling out because it's a load-bearing kwarg, but the current code is right. - Confirmed
AIMessageChunk.content_blocksnormalizes plain string content into[{type:"text", text:...}], so both string-content Bedrock models and native block outputs land as text throughparseAgentEvent. init_chat_model("...", model_provider="bedrock_converse")resolves againstlangchain-aws~=1.7.5fine (only AWS credential/region errors surface, which is the deploy-time contract).- The
parseAgentEventextension is properly ordered aftererror/text, guarded onArray.isArray, and the new test covering a tool-call-only chunk correctly asserts it's dropped. - The AG-UI snapshot deletion in
manager.test.ts.snaplooks alarming at first glance but the commit message and prior #2214 confirm it was already an orphan snapshot; the new LangChain snapshot replaces the slot. - The reordered
TEMPLATE_OPTIONSstill keys offagent-python-strandsas the default inemptyCreateProjectForm, and the wizard tests'up/upnavigation matches the new list order. - Tests use the real HTTP server harness (
sseAgent/ServerFarm) rather than mocks — good.
Non-blocking observations, take or leave:
context.session_id or "default-session"willAttributeErrorifsession_idis ever missing from the context;agent-python-strands/main.pyuses the defensivegetattr(context, "session_id", "default-session"). Not a real risk givenBedrockAgentCoreAppalways populates it, just an inconsistency between the two templates.pyproject.tomlpinsaws-opentelemetry-distro ~= 0.19.0andbedrock-agentcore ~= 1.22.0, both newer than whatagent-python-strandsships (~= 0.18.0/~= 1.9.1). Presumably intentional, but worth keeping the templates in sync eventually.
LGTM to merge.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #2230 +/- ##
=========================================
Coverage 96.97% 96.97%
=========================================
Files 559 559
Lines 38609 38637 +28
=========================================
+ Hits 37440 37468 +28
Misses 1169 1169 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…last in the agent group
|
Claude Security Review: no high-confidence findings. (run) |
|
Claude Security Review: no high-confidence findings. (run) |
…er from the preset table Each preset carries its description, and the name list is sorted by protocol, then language, framework, and build through typed rank tables. Adding a framework without ranking it fails to compile, so a new template lands in the right place in both the wizard and the --template help without touching a hand-ordered list.
|
Claude Security Review: no high-confidence findings. (run) |
Keeps both the langchain and vercelai frameworks, gives the Vercel preset the description the derived wizard list needs, ranks vercelai after langchain, and steps up to agent code in the wizard test now that harness is listed second.
|
Claude Security Review: no high-confidence findings. (run) |
Agent code is now the default project kind and the recommended suffix is gone, so the derived template list labels entries by name only and the LangChain wizard test accepts the default type.
|
Claude Security Review: no high-confidence findings. (run) |
Problem
The refactor branch has no LangChain template. The legacy LangGraph template used the deprecated
create_react_agent, unbounded>=pins, and Handlebars branches (filesystem mounts, config bundle, gateway MCP client) that the refactor never renders.Solution
agent-python-langchain: a Bedrock-backed LangChain agent on AgentCore Runtime, selectable with--templateand in the create wizard, on bothproject createandproject add runtime.create_agentfromlangchain.agents(the langgraph source markscreate_react_agentdeprecated in favour of it). Model frominit_chat_model(..., model_provider="bedrock_converse")inmodel/load.py, same Claude Sonnet 4.5 profile as the Strands template.name.InMemorySavercheckpointer keyed on the Runtime session id gives multi-turn history within a session. No eviction, since each Runtime session runs in its own microVM.{node, content: [blocks]}, tool-call chunks included. A missing or non-stringpromptyields one{error}event and stops instead of raising.opentelemetry-instrumentation-langchainin the dependencies, no explicit instrument call, picked up by ADOT when the L3 construct wraps the CodeZip entrypoint inopentelemetry-instrument.~=: langchain 1.4.0, langgraph 1.2.11, langchain-aws 1.7.5, bedrock-agentcore 1.22.0, aws-opentelemetry-distro 0.19.0, opentelemetry-instrumentation-langchain 0.62.3.CLI side: one
langchainframework value, one preset, one resolver keyedlangchain/Python/HTTP, one wizard entry.Two adjacent changes came out of testing:
parseAgentEventin the Agent Inspector proxy only knew the Strands ConverseStream shape,{text},{error}, and bare strings, so the LangChain stream showed "(empty response)" in the inspector chat. It now joins the text blocks of a{content: [...]}chunk into a text frame and drops tool-call-only chunks.(CodeZip build)/(container build)suffixes are gone since the names carry that. Every row fits on one line at 110 columns.Recording the manifest snapshot also pruned an orphaned Strands AG-UI snapshot whose test was removed in #2214.
Verification
Unit:
bun test(2993 pass),tsc,oxlint,prettier --check.