feat(adapters): add LangChain export adapter & runner with multi-provider support#81
Open
AJAmit17 wants to merge 4 commits into
Open
feat(adapters): add LangChain export adapter & runner with multi-provider support#81AJAmit17 wants to merge 4 commits into
AJAmit17 wants to merge 4 commits into
Conversation
Adds LangChain as a new export/run target alongside existing adapters (kiro, gitclaw, codex, etc.) — no existing adapters removed or modified. - src/adapters/langchain.ts: exports agent YAML → standalone Python script using LangChain agent framework; multi-provider support (OpenAI / Anthropic) via model-name prefix detection; tool stubs via @tool decorators; sub-agent delegation; system prompt from SOUL.md + RULES.md + skills - src/runners/langchain.ts: runs an agent via a temporary Python venv; bootstraps pip deps, writes the generated script, executes it - src/adapters/langchain.test.ts: unit tests for provider detection and export - docs/adapters/langchain.md: field-mapping table, provider table, usage examples Integration wired into: - src/adapters/index.ts — export added (additive) - src/commands/export.ts — 'langchain' case added; format list updated - src/commands/run.ts — 'langchain' case added; adapter list updated
9 tasks
…gap from open-gitagent#79) PR open-gitagent#79 added financial_governance references in validate.ts and shared.ts but the property was never declared on ComplianceConfig in loader.ts, causing a TypeScript build failure on all Node versions in CI.
…ernance validation
…pen-gitagent#74) - docs/adapters/langchain.md: gitagent <verb> → gapman <verb> in all CLI examples; @shreyaskapale/gitagent → @open-gitagent/gapman package ref - src/adapters/langchain.ts: 'Generated by gitagent export' → 'Generated by gapman export' (user-visible string in generated scripts) - src/runners/langchain.ts: venv path gitagent-env → langchain-venv (matches the path documented in the PR and adapter docs) Prose references to 'gitagent' as the protocol/project name preserved as per open-gitagent#74 policy.
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
This is a clean rebase of #16 onto current
main. The original PR predated several merges that touched the same integration files (src/adapters/index.ts,src/commands/export.ts,src/commands/run.ts), making the diff unreadable. This branch is three focused commits on top ofb3a057awith all conflicts resolved — no existing adapters or options were removed.Original PR: #16 (superseded by this one — closed)
Closes: #2
Hey @shreyas-lyzr — this is the clean rebase you asked for. Quick summary of what changed since #16:
main(b3a057a) as a single feature commit — no merge noisesrc/adapters/index.ts,src/commands/export.ts,src/commands/run.ts) updated additively — kiro, gitclaw,--workspace, andexportToClaudeCodeStringare all intactWhat this adds
LangChain as a first-class export + run target alongside the existing adapters (kiro, gitclaw, codex, etc.):
src/adapters/langchain.tsagent.yaml→ standalone Python script using LangChain agent frameworksrc/runners/langchain.ts~/.gitagent/langchain-venvsrc/adapters/langchain.test.tsdocs/adapters/langchain.mdIntegration changes (additive only):
src/adapters/index.ts—exportToLangChainadded as a new export linesrc/commands/export.ts—langchaincase added; format help string updatedsrc/commands/run.ts—langchaincase added; adapter help string updatedAlso fixes: pre-existing TypeScript build failure from #79
PR #79 added
financial_governancereferences insrc/commands/validate.tsandsrc/adapters/shared.tsbut the property was never declared onComplianceConfiginsrc/utils/loader.ts, causing a TypeScript build failure on all Node versions in CI. This PR adds the missing type declaration and guards the unsafe<= 0comparison that the strict types exposed.Addressing reviewer questions from #16
Q: Is
runWithLangChaininvoking the user's installed Python LangChain (subprocess) or shipping a JS LangChain runtime?Subprocess. The runner (
src/runners/langchain.ts) bootstraps a Python venv at~/.gitagent/langchain-venvon first run, installs the requiredlangchain-openaiorlangchain-anthropicpip package depending on the detected provider, writes the generated Python script to a temp file, then invokes it viaspawnSync. No JS LangChain runtime is shipped.Q: Multi-provider switching — provider precedence and conflict behaviour?
Provider is determined solely from
manifest.model.preferred(the model name string). The detection rules:claude-*→ Anthropic (langchain-anthropic,ANTHROPIC_API_KEY)gpt-*,o1-*/o2-*/o3-*/o4-*→ OpenAI (langchain-openai,OPENAI_API_KEY)The corresponding env var must be set at runtime; the runner validates and errors clearly if it is missing. There is no silent fallback between providers.
Q: Fidelity matrix row?
Happy to add a row to
paper/tables/fidelity-matrix.csvin a follow-up, or I can include it here if preferred — just say the word.Note on scope vs #80 (LangGraph + DeepAgents)
PR #80 added LangGraph (the state-machine layer on top of LangChain) and DeepAgents (a higher-level harness). This PR adds the base LangChain runtime. They compose — LangGraph imports from LangChain — so this is the foundational piece, not a duplicate.
Test plan
npm run buildpasses (Node 18 / 20 / 22)gitagent export --format langchain -d <agent-dir>produces a valid Python scriptgitagent run -a langchain -d <agent-dir> -p "hello"bootstraps venv and executeslangchain.test.ts)ComplianceConfigtype fix unblocks CI for all open PRs targetingmain