Skip to content

feat(adapters): added LangGraph and DeepAgents export adapters#80

Open
krishvsoni wants to merge 1 commit into
open-gitagent:mainfrom
krishvsoni:feat/1-langgraph-adapter
Open

feat(adapters): added LangGraph and DeepAgents export adapters#80
krishvsoni wants to merge 1 commit into
open-gitagent:mainfrom
krishvsoni:feat/1-langgraph-adapter

Conversation

@krishvsoni
Copy link
Copy Markdown

feat(adapters): added LangGraph and DeepAgents export adapters

  • Implemented exportToLangGraph and exportToLangGraphString functions in src/adapters/langgraph.ts to convert agent configurations into LangGraph Python code.
  • Implemented exportToDeepAgents and exportToDeepAgentsString functions in src/adapters/deepagents.ts to emit a create_deep_agent(...) LangChain DeepAgents harness — skills, tools, and sub-agents map directly; no graph wiring.
  • Created comprehensive test suites in src/adapters/langgraph.test.ts (18 tests) and src/adapters/deepagents.test.ts (13 tests) to validate the output of the export functions, ensuring correct handling of agent metadata, skills, tools, skillflows, hooks, and sub-agents.
  • Added helper functions for YAML rendering and agent directory structure creation to facilitate testing.
  • Ensured compatibility with existing agent structures by supporting both skillflows/ and workflows/ directories.

What

Adds two new export adapters to gitagent:

  • langgraph : converts a gitagent directory into a runnable LangGraph StateGraph Python module. Skills become nodes, skillflows/*.yaml become add_edge / add_conditional_edges, tools/*.yaml bind to a ToolNode, pre_tool_use hooks become a before_tool callback, and agents/<name>/ become nested compiled StateGraphs.
  • deepagents : converts a gitagent directory into a create_deep_agent(...) call. Skills are passed via skills=["./skills"] (DeepAgents reads each SKILL.md natively), tools are @tool defs in tools=[...], and sub-agents become SubAgent dicts in subagents=[...]. Use this when you want the model to orchestrate planning and delegation instead of authoring a graph by hand.

Why

Issue #1 has been open since Feb 27 and the @shreyas-lyzr 's most recent comment asked for LangGraph proper as the natural sibling of the in-flight LangChain adapter (PR #16), with the explicit mapping agent.yaml → StateGraph config, skills/ → nodes, skillflows/*.yaml → edges + conditional routing. The maintainer's earlier comment in the same thread linked the DeepAgents overview as a possible alternative — shipping it as a sibling adapter gives users both paths (explicit graph wiring vs. LLM-orchestrated harness) without forcing a choice.

Closes #1

How Tested

  • npm run build passes
  • gitagent validate passes on example agents
  • Manual testing (describe below)

Ran both adapters end-to-end against examples/langgraph, examples/deepagents, and the bundled examples/full compliance agent (sub-agents, workflow with depends_on, hooks, FINRA / Federal Reserve / SEC compliance block). Diffed each export against the committed expected_output.py and verified syntactic validity with ast.parse. Full suite is 60/60 across 11 suites — 18 new LangGraph tests + 13 new DeepAgents tests, no pre-existing tests modified.

$ npm run build
> tsc && chmod +x dist/index.js

$ node dist/index.js export --dir examples/langgraph --format langgraph -o /tmp/lg.py
✓ Exported to /tmp/lg.py
$ node dist/index.js export --dir examples/deepagents --format deepagents -o /tmp/da.py
✓ Exported to /tmp/da.py

$ python -c "import ast; ast.parse(open('/tmp/lg.py').read()); print('OK')"
OK
$ python -c "import ast; ast.parse(open('/tmp/da.py').read()); print('OK')"
OK

$ npm test
# tests 60
# suites 11
# pass 60
# fail 0

Checklist

  • My code follows the existing style of this project
  • I have added/updated tests (if applicable)
  • I have updated documentation (if applicable)
  • I have read the CONTRIBUTING.md

- Implemented  and  functions in  to convert agent configurations into LangGraph Python code.
- Created a comprehensive test suite in  to validate the output of the export functions, ensuring correct handling of agent metadata, skills, tools, skillflows, and hooks.
- Added helper functions for YAML rendering and agent directory structure creation to facilitate testing.
- Ensured compatibility with existing agent structures by supporting both  and  directories.
@shreyas-lyzr
Copy link
Copy Markdown
Contributor

This is a serious piece of work. Brutally honest review:

What's right:

  • The mapping documented in src/adapters/langgraph.ts header is exactly the right shape — agent.yaml → StateGraph config, SOUL/RULES/DUTIES → system prompt, skills/<name>/SKILL.md → graph node, skillflows/*.yaml → add_edge / add_conditional_edges, tools/*.yaml → ToolNode, pre_tool_use → before_tool, agents/<name>/ → nested compiled StateGraph. That's the canonical correspondence — every element of GAP maps to something in LangGraph.
  • Shipping DeepAgents alongside LangGraph as the LLM-orchestrated harness alternative (no explicit graph wiring) is a smart sibling — gives users both paths. The cleanest is the skills=["./skills"] integration since DeepAgents reads SKILL.md natively.
  • 18 + 13 = 31 tests with regex assertions against the generated Python, plus ast.parse validation. That's how adapter tests should look — not stubs.
  • examples/langgraph/ and examples/deepagents/ include expected_output.py artifacts. Diff-testable.
  • Closes [Adapter] LangGraph export/runner #1 (LangGraph adapter request open since Feb 27).

One thing for a follow-up (not a blocker):
The paper/open-gap.md Appendix B fidelity matrix should add rows for langgraph and deepagents. Will add this myself in a doc-only follow-up.

Merging.

@shreyas-lyzr
Copy link
Copy Markdown
Contributor

Hit a clean merge conflict — PR #66 (mcp_servers) just merged minutes before this and also touches src/commands/export.ts and src/adapters/index.ts. Bad timing on my part — I should have merged in the other order.

Quick rebase needed against the new main. The conflict footprint is tiny: just the two integration files at the bottom of the export switch and the adapters/index re-exports. The actual langgraph.ts and deepagents.ts files are untouched by #66 and will rebase clean.

If you push a rebase, I'll merge same-day (less than an hour if I'm at a keyboard). If easier, I'm happy to rebase locally and force-push to your branch myself — your call. Either way the merge is approved on the substance.

Apologies for the conflict — that one was on me.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Adapter] LangGraph export/runner

2 participants