Skip to content

feat: Native framework integration for LangChain, CrewAI, AutoGen, LlamaIndex#2

Closed
ryandao wants to merge 3 commits intomainfrom
devsquad/theo/1776036423915
Closed

feat: Native framework integration for LangChain, CrewAI, AutoGen, LlamaIndex#2
ryandao wants to merge 3 commits intomainfrom
devsquad/theo/1776036423915

Conversation

@ryandao
Copy link
Copy Markdown
Owner

@ryandao ryandao commented Apr 12, 2026

Summary

  • Auto-detection: FrameworkDetector inspects sys.modules and importlib to detect which agent frameworks (LangChain, CrewAI, AutoGen, LlamaIndex) are installed and active at runtime
  • Adapter pattern: Each framework gets a dedicated adapter that monkey-patches core execution methods to emit lifecycle events — no @agent decorator needed
  • Simple API: Users call agentq_sdk.auto_integrate() (one-liner) or use AgentQ() as a context manager to activate framework integration
  • Clean unpatch: All adapters store direct class references for reliable restoration of original methods

Architecture

agentq_sdk/
├── __init__.py          # Public API surface
├── core.py              # AgentQ class + auto_integrate()
├── detection.py         # Framework detection engine
├── registry.py          # Singleton adapter registry
└── adapters/
    ├── base.py          # BaseAdapter ABC + event system
    ├── langchain.py     # AgentExecutor.invoke + LCEL RunnableSequence
    ├── crewai.py        # Crew.kickoff + Agent.execute_task
    ├── autogen.py       # ConversableAgent.initiate_chat + generate_reply
    └── llamaindex.py    # ReActAgent/AgentRunner chat + query

Test plan

  • 52 unit tests covering detection, registry, core module, and all 4 adapters
  • Mock-based testing (frameworks not required in test env)
  • Patch/unpatch roundtrip verified for each adapter
  • Error event emission tested (exceptions propagated, events emitted)
  • Adapter interface consistency checked via parametrized tests

🤖 Generated with Claude Code

ryandao and others added 3 commits April 12, 2026 16:36
…, and LlamaIndex

Implement auto-detection and seamless integration with popular agent frameworks
so the @agent decorator is not required. The SDK detects installed frameworks
at runtime and monkey-patches their core execution methods to emit lifecycle
events (start/end/error, step, tool call, LLM call).

Architecture:
- detection.py: Framework detection via importlib + sys.modules inspection
- registry.py: Singleton adapter registry mapping frameworks to adapters
- core.py: AgentQ class with context manager + auto_integrate() one-liner
- adapters/base.py: BaseAdapter ABC with event emission infrastructure
- adapters/langchain.py: Hooks AgentExecutor.invoke and LCEL RunnableSequence
- adapters/crewai.py: Hooks Crew.kickoff and Agent.execute_task
- adapters/autogen.py: Hooks ConversableAgent.initiate_chat and generate_reply
- adapters/llamaindex.py: Hooks ReActAgent/AgentRunner chat and query methods

All adapters store direct class references for reliable unpatch, and all
52 unit tests pass covering detection, registry, core, and all 4 adapters.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryandao ryandao closed this Apr 13, 2026
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.

1 participant