Skip to content

feat(templates): add the agent-python-langchain template - #2230

Merged
tejaskash merged 12 commits into
refactorfrom
feat/agent-python-langchain
Sep 4, 2026
Merged

feat(templates): add the agent-python-langchain template#2230
tejaskash merged 12 commits into
refactorfrom
feat/agent-python-langchain

Conversation

@tejaskash

@tejaskash tejaskash commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

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 --template and in the create wizard, on both project create and project add runtime.

  • Built with create_agent from langchain.agents (the langgraph source marks create_react_agent deprecated in favour of it). Model from init_chat_model(..., model_provider="bedrock_converse") in model/load.py, same Claude Sonnet 4.5 profile as the Strands template.
  • HTTP, CodeZip, Bedrock only. No AgentCore Memory, no MCP client, no container preset. The only Handlebars variable is name.
  • InMemorySaver checkpointer keyed on the Runtime session id gives multi-turn history within a session. No eviction, since each Runtime session runs in its own microVM.
  • Async generator entrypoint streams each model chunk as {node, content: [blocks]}, tool-call chunks included. A missing or non-string prompt yields one {error} event and stops instead of raising.
  • OTEL is always on: opentelemetry-instrumentation-langchain in the dependencies, no explicit instrument call, picked up by ADOT when the L3 construct wraps the CodeZip entrypoint in opentelemetry-instrument.
  • Versions were resolved by installing the latest of everything on Python 3.14 and running the agent against Bedrock, then pinned with ~=: 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.
  • The generated README has an "Extending" section covering tools, middleware, a durable checkpointer, and structured output.

CLI side: one langchain framework value, one preset, one resolver keyed langchain/Python/HTTP, one wizard entry.

Two adjacent changes came out of testing:

  • parseAgentEvent in 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.
  • The wizard template list is ordered by type, then language, then framework, and the (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.

  • Dev and Deploy
Screenshot 2026-09-04 at 3 15 52 PM

…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.
@github-actions github-actions Bot added the size/m PR size: M label Sep 4, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Sep 4, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 4, 2026

@agentcore-devx-automation agentcore-devx-automation Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.0 that agent.astream(..., stream_mode="messages", version="v2") yields {"type":"messages","data":(AIMessageChunk, metadata)} dicts, so the event["data"] destructure in main.py is correct. Without version="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_blocks normalizes plain string content into [{type:"text", text:...}], so both string-content Bedrock models and native block outputs land as text through parseAgentEvent.
  • init_chat_model("...", model_provider="bedrock_converse") resolves against langchain-aws~=1.7.5 fine (only AWS credential/region errors surface, which is the deploy-time contract).
  • The parseAgentEvent extension is properly ordered after error/text, guarded on Array.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.snap looks 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_OPTIONS still keys off agent-python-strands as the default in emptyCreateProjectForm, and the wizard tests' up/up navigation 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" will AttributeError if session_id is ever missing from the context; agent-python-strands/main.py uses the defensive getattr(context, "session_id", "default-session"). Not a real risk given BedrockAgentCoreApp always populates it, just an inconsistency between the two templates.
  • pyproject.toml pins aws-opentelemetry-distro ~= 0.19.0 and bedrock-agentcore ~= 1.22.0, both newer than what agent-python-strands ships (~= 0.18.0 / ~= 1.9.1). Presumably intentional, but worth keeping the templates in sync eventually.

LGTM to merge.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Sep 4, 2026
@codecov-commenter

codecov-commenter commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.97%. Comparing base (23df65f) to head (e1df24a).

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.
📢 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.

@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Sep 4, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 4, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Sep 4, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot added claude-security-reviewing Claude Code /security-review in progress and removed claude-security-reviewing Claude Code /security-review in progress labels Sep 4, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 4, 2026
…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.
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Sep 4, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 4, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 4, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Sep 4, 2026
AlexanderRichey
AlexanderRichey previously approved these changes Sep 4, 2026
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.
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Sep 4, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 4, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 4, 2026
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.
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Sep 4, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 4, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 4, 2026
@tejaskash
tejaskash merged commit ad3d69d into refactor Sep 4, 2026
17 checks passed
@tejaskash
tejaskash deleted the feat/agent-python-langchain branch September 4, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants