Skip to content

feat(adapter): add LangGraph export and run adapter#26

Open
dahlinomine wants to merge 1 commit intoopen-gitagent:mainfrom
dahlinomine:feat/langgraph-adapter
Open

feat(adapter): add LangGraph export and run adapter#26
dahlinomine wants to merge 1 commit intoopen-gitagent:mainfrom
dahlinomine:feat/langgraph-adapter

Conversation

@dahlinomine
Copy link
Contributor

Summary

Adds langgraph as a new export format and run adapter.

Closes #1.

Changes

  • src/adapters/langgraph.ts — exports a gitagent directory as a LangGraph StateGraph Python script using the ReAct pattern with ToolNode and conditional routing
  • src/runners/langgraph.ts — runs the exported graph script via python3
  • Multi-agent topology: sub-agents defined in agent.yaml are annotated with guidance for LangGraph supervisor-node patterns
  • Compliance constraints (FINRA 2210, 17a-4, SOD conflicts) are injected into the system SYSTEM_PROMPT constant
  • Model routing: gpt-4o default, claude-*ChatAnthropic, gemini-*ChatGoogleGenerativeAI

Usage

# Export to a LangGraph Python script
gitagent export -f langgraph -d ./my-agent -o agent_graph.py

# Run directly
gitagent run -a langgraph -d ./my-agent

Generated output example

Given an agent with a research skill and claude-3-5-sonnet-20241022 model:

from langgraph.graph import StateGraph, END
from langgraph.prebuilt import ToolNode
from langchain_anthropic import ChatAnthropic

class AgentState(TypedDict):
    messages: Annotated[Sequence[BaseMessage], operator.add]

@tool
def research(input: str) -> str:
    """Research a topic..."""
    raise NotImplementedError("research not yet implemented")

tools = [research]
llm = ChatAnthropic(model="claude-3-5-sonnet-20241022", temperature=0.3)
llm_with_tools = llm.bind_tools(tools)
# ... StateGraph wiring ...
graph = workflow.compile()

Testing

  • npm run build passes
  • gitagent export -f langgraph -d examples/standard produces valid Python
  • gitagent export -f langgraph -d examples/full renders compliance constraints

Checklist

  • Follows the existing adapter pattern (crewai, openai, lyzr)
  • Runner follows the existing runner pattern (runners/openai.ts)
  • Wired into adapters/index.ts, commands/export.ts, commands/run.ts
  • No new dependencies added
  • Conventional commit message

Adds `langgraph` as a new export format and run adapter. Closes open-gitagent#1.

- src/adapters/langgraph.ts: exports gitagent definition as a LangGraph
  StateGraph (ReAct pattern) with ToolNode and conditional routing
- src/runners/langgraph.ts: runs the exported graph script via python3
- Multi-agent topology: sub-agents from agent.yaml are annotated with
  guidance for supervisor-node patterns
- Compliance constraints injected into system prompt including SOD conflicts
- Model routing: gpt-4o (default), claude-* → ChatAnthropic, gemini-* → ChatGoogleGenerativeAI
@shreyas-lyzr
Copy link
Contributor

can we create a adapter for DeepAgents instead? https://docs.langchain.com/oss/python/deepagents/overview

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