Skip to content

feat: add honcho-agno integration package#320

Open
ajspig wants to merge 12 commits intomainfrom
abigail/dev-1334
Open

feat: add honcho-agno integration package#320
ajspig wants to merge 12 commits intomainfrom
abigail/dev-1334

Conversation

@ajspig
Copy link
Contributor

@ajspig ajspig commented Jan 12, 2026

  • HonchoTools class with 5 memory tools (add_message, get_context, search_messages, query_user, reset_session)
  • Example scripts demonstrating usage with Agno agents
  • Comprehensive test suite

Summary by CodeRabbit

  • New Features

    • Introduced HonchoAgno Python integration package with context retrieval, message search, and chat capabilities.
  • Documentation

    • Added comprehensive README with installation, configuration, environment setup, and usage examples.
    • Added example script demonstrating HonchoAgno integration workflow.
    • Added project configuration and license files.

✏️ Tip: You can customize this high-level summary in your review settings.

   Add Agno framework integration following the Toolkit pattern:
   - HonchoTools class with 5 memory tools (add_message, get_context,
     search_messages, query_user, reset_session)
   - Example scripts demonstrating usage with Agno agents
   - Comprehensive test suite
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 12, 2026

Walkthrough

This PR introduces a new Honcho-Agno integration package under examples/agno/python/, providing HonchoTools for Agno agents to access Honcho's memory system through three read-only tools: context retrieval, semantic message search, and user insight queries. Includes project configuration, comprehensive documentation, and example usage.

Changes

Cohort / File(s) Summary
Licensing & Documentation
examples/agno/python/LICENSE, examples/agno/python/README.md
Adds AGPL v3 license text and comprehensive documentation covering installation, configuration, tool usage, multi-peer patterns, architecture notes, and development instructions.
Package Configuration & Initialization
examples/agno/python/pyproject.toml, examples/agno/python/src/honcho_agno/__init__.py
Defines project metadata, dependencies (agno, honcho-ai), build configuration, and public API exports; initializes package version and exports HonchoTools.
Core Toolkit Implementation
examples/agno/python/src/honcho_agno/tools.py
Implements HonchoTools class providing three methods—honcho_get_context, honcho_search_messages, honcho_chat—that enable Agno agents to query Honcho's memory system with error handling and logging.
Example & Usage
examples/agno/python/examples/simple_example.py
Demonstrates RunContext integration with Honcho and Agno, showing initialization, agent configuration, and session persistence.

Sequence Diagram(s)

sequenceDiagram
    participant Agent as Agno Agent
    participant Tools as HonchoTools
    participant Client as Honcho Client
    participant Backend as Honcho Backend

    Agent->>Tools: honcho_get_context(run_context)
    activate Tools
    Tools->>Client: get_context(session_id, user_id)
    activate Client
    Client->>Backend: fetch session context
    activate Backend
    Backend-->>Client: context data
    deactivate Backend
    Client-->>Tools: formatted context
    deactivate Client
    Tools-->>Agent: context string
    deactivate Tools

    Agent->>Tools: honcho_search_messages(run_context, query)
    activate Tools
    Tools->>Client: search(session_id, query)
    activate Client
    Client->>Backend: semantic search
    activate Backend
    Backend-->>Client: matching messages
    deactivate Backend
    Client-->>Tools: search results
    deactivate Client
    Tools-->>Agent: results string
    deactivate Tools
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Adding crewAI integration guide #279: Introduces parallel Honcho integration package (honcho_crewai) with similar toolkit architecture, tool methods (get_context, search_messages), and package initialization patterns, indicating coordinated multi-framework support.

Suggested reviewers

  • VVoruganti
  • Rajat-Ahuja1997

Poem

🐰 A toolkit so fine, now Agno can thrive,
Honcho memories shared, keeping agents alive,
Tools to search and retrieve with flair,
Context and wisdom floating through the air! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: introducing a new honcho-agno integration package with HonchoTools for Agno agents.
Docstring Coverage ✅ Passed Docstring coverage is 82.35% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@ajspig ajspig marked this pull request as ready for review January 15, 2026 19:15
@ajspig
Copy link
Contributor Author

ajspig commented Jan 15, 2026

  • Intentionally didn’t expose the target parameter in the chat tool to keep things simple. The current session-scoped approach (session=self.session_id) already provides useful context. It felt like it would add additional complexity to ensure the agent called the tools with the correct peer_id. My thought was for advanced multi-peer scenarios, users can use the SDK directly.
    • It wouldn't be that hard to add it though. I’d make it a separate tool and have it call honcho_list_peers() to discover all available peers.
  • Each toolkit is specific to the agent that uses it. Additional orchestration outside of the toolkit is needed to add messages and other peers to honcho.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@examples/agno/python/examples/multi_tool_example.py`:
- Around line 44-48: The HonchoTools instantiation uses a hardcoded session_id
("trip-planning-session") which causes message accumulation; change it to
generate a unique session id (e.g., use uuid.uuid4()) when creating HonchoTools
(the session_id argument of HonchoTools) and ensure uuid is imported at the top
of the file so each run gets a new session_id.

In `@examples/agno/python/pyproject.toml`:
- Around line 35-38: The dependencies list in pyproject.toml pins "agno>=1.4.0"
which is outdated; update the dependencies array entry for the package named
"agno" to use a current 2.x constraint (e.g. change the "agno>=1.4.0" entry to
"agno>=2.3.26") while leaving "honcho-ai>=1.6.0" as-is, and then regenerate your
lockfile (or reinstall dependencies) to ensure the updated version is used.
🧹 Nitpick comments (6)
examples/agno/python/src/honcho_agno/tools.py (1)

125-159: Consider validating the limit parameter.

The docstring states limit accepts values 1-100, but there's no validation to enforce this range. Invalid values would be passed to the Honcho API, potentially causing unexpected behavior.

🔧 Optional: Add limit validation
     def honcho_search_messages(
         self,
         query: str,
         limit: int = 10,
     ) -> str:
         """
         Search through session messages using semantic similarity.

         Use this tool to find relevant past messages from the conversation
         history based on semantic meaning rather than exact keyword matching.

         Args:
             query: Search query for semantic matching.
             limit: Number of results to return (1-100).

         Returns:
             Formatted string with search results.
         """
         try:
+            limit = max(1, min(100, limit))  # Clamp to valid range
             messages = self.session.search(query=query, limit=limit)
examples/agno/python/examples/simple_example.py (1)

55-83: Consider adding error handling around API calls.

The agent.run() call and honcho_tools.session.add_messages() can fail due to network issues or API errors. For a robust example, consider wrapping these in try/except blocks.

Example error handling pattern
     # The agent can now query memories and provide personalized responses
     print("\nAsking the agent for recommendations...")
-    response = agent.run(
-        "Based on what you know about the user, what should they learn next? "
-        "Use the honcho_chat tool to understand their interests first."
-    )
+    try:
+        response = agent.run(
+            "Based on what you know about the user, what should they learn next? "
+            "Use the honcho_chat tool to understand their interests first."
+        )
+    except Exception as e:
+        print(f"Error running agent: {e}")
+        return
examples/agno/python/examples/multi_peer_example.py (1)

113-151: Consider handling potential API failures in the interactive loop.

The agent.run() calls on lines 140 and 147 could fail due to network issues or rate limiting, which would crash the interactive session. A try/except block would make this more resilient for demos.

Example resilient loop pattern
         # Tech Bro responds
         print()
         print("-" * 40)
-        tech_response = tech_bro_agent.run(user_input)
-        tech_content = str(tech_response.content) if tech_response.content else ""
-        session.add_messages([tech_bro_tools.peer.message(tech_content)])
-        print(f"Tech Bro: {tech_content}\n")
+        try:
+            tech_response = tech_bro_agent.run(user_input)
+            tech_content = str(tech_response.content) if tech_response.content else ""
+            session.add_messages([tech_bro_tools.peer.message(tech_content)])
+            print(f"Tech Bro: {tech_content}\n")
+        except Exception as e:
+            print(f"Tech Bro error: {e}\n")
examples/agno/python/examples/multi_tool_example.py (1)

63-65: Consider using batch add_messages for consistency.

The simple_example.py (lines 57-60) uses batch message addition with a list, while this iterates and adds one message at a time. Batch addition is more efficient and consistent with other examples.

Suggested batch pattern
-    for msg in messages:
-        honcho_tools.session.add_messages([user_peer.message(msg)])
-        print(f"  [traveler-42]: {msg[:50]}...")
+    honcho_tools.session.add_messages([user_peer.message(msg) for msg in messages])
+    for msg in messages:
+        print(f"  [traveler-42]: {msg}")
examples/agno/python/tests/test_tools.py (2)

45-51: UUID validation could use explicit assertion.

The uuid.UUID() call will raise ValueError if invalid, which is fine, but an explicit assertion would make the test intent clearer.

More explicit assertion
     def test_auto_generates_session_id(self, mock_client):
         """Test session_id is auto-generated if not provided."""
         tools = HonchoTools(honcho_client=mock_client)

         assert tools.session_id is not None
         # Should be valid UUID
-        uuid.UUID(tools.session_id)
+        parsed = uuid.UUID(tools.session_id)
+        assert str(parsed) == tools.session_id

104-115: Add tests for tool execution with mocked responses to validate integration behavior.

The current tests verify structure, registration, and initialization, but don't test that tools return expected values when called. The tools (honcho_get_context, honcho_search_messages, honcho_chat) are designed to return formatted strings based on client responses. Adding an execution test would increase confidence in the integration. For example:

Example test for tool execution
def test_honcho_chat_returns_response(self, mock_client):
    """Test honcho_chat returns the mocked response."""
    mock_client.peer.return_value.chat.return_value = "Test insight"
    tools = HonchoTools(
        peer_id="test-agent",
        honcho_client=mock_client,
    )
    
    result = tools.honcho_chat("What does the user prefer?")
    
    assert result is not None
    assert isinstance(result, str)
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 578ef2c and 5837c7a.

⛔ Files ignored due to path filters (1)
  • examples/agno/python/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • examples/agno/python/LICENSE
  • examples/agno/python/README.md
  • examples/agno/python/examples/multi_peer_example.py
  • examples/agno/python/examples/multi_tool_example.py
  • examples/agno/python/examples/simple_example.py
  • examples/agno/python/pyproject.toml
  • examples/agno/python/src/honcho_agno/__init__.py
  • examples/agno/python/src/honcho_agno/py.typed
  • examples/agno/python/src/honcho_agno/tools.py
  • examples/agno/python/tests/test_tools.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: Follow isort conventions with absolute imports preferred
Use snake_case for variables/functions; PascalCase for classes
Line length: 88 chars (Black compatible)
Use explicit error handling with appropriate exception types from src/exceptions.py
Use Google style docstrings
Use custom exceptions from src/exceptions.py and log with context instead of using print statements

Files:

  • examples/agno/python/examples/multi_tool_example.py
  • examples/agno/python/examples/multi_peer_example.py
  • examples/agno/python/examples/simple_example.py
  • examples/agno/python/tests/test_tools.py
  • examples/agno/python/src/honcho_agno/__init__.py
  • examples/agno/python/src/honcho_agno/tools.py
🧠 Learnings (7)
📚 Learning: 2026-01-12T20:13:02.423Z
Learnt from: CR
Repo: plastic-labs/honcho PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T20:13:02.423Z
Learning: Applies to src/utils/agent_tools.py : All agents share common infrastructure in src/utils/agent_tools.py with unified tool schemas, context-aware tool executors, and configurable LLM client

Applied to files:

  • examples/agno/python/README.md
  • examples/agno/python/examples/multi_tool_example.py
  • examples/agno/python/src/honcho_agno/__init__.py
  • examples/agno/python/src/honcho_agno/tools.py
📚 Learning: 2026-01-06T15:23:27.596Z
Learnt from: dr-frmr
Repo: plastic-labs/honcho PR: 309
File: src/utils/clients.py:317-330
Timestamp: 2026-01-06T15:23:27.596Z
Learning: When reviewing Python code that uses the google.genai SDK, ensure that tool definitions are wrapped with a function_declarations array of objects like [{"function_declarations": [{"name": ..., "description": ..., "parameters": ...}]}]. Do not use the Gemini REST API format (which uses a flat array of tool objects). This wrapper is required by the Google GenAI Python SDK for proper tool metadata structure.

Applied to files:

  • examples/agno/python/examples/multi_tool_example.py
  • examples/agno/python/examples/multi_peer_example.py
  • examples/agno/python/examples/simple_example.py
  • examples/agno/python/tests/test_tools.py
  • examples/agno/python/src/honcho_agno/__init__.py
  • examples/agno/python/src/honcho_agno/tools.py
📚 Learning: 2026-01-06T15:32:06.942Z
Learnt from: dr-frmr
Repo: plastic-labs/honcho PR: 309
File: src/utils/clients.py:253-265
Timestamp: 2026-01-06T15:32:06.942Z
Learning: Use new per-level provider configuration under settings.DIALECTIC.LEVELS. Ensure code reads provider values from this nested structure instead of a global DIALECTIC_PROVIDER. In CI, overrides must use nested environment variables following the double-underscore naming convention: DIALECTIC__LEVELS__<level>__PROVIDER (e.g., DIALECTIC__LEVELS__minimal__PROVIDER). Do not rely on legacy DIALECTIC_PROVIDER to change all levels by default. Update config loading and tests to reflect per-level provider wiring and environment override behavior.

Applied to files:

  • examples/agno/python/examples/multi_tool_example.py
  • examples/agno/python/examples/multi_peer_example.py
  • examples/agno/python/examples/simple_example.py
  • examples/agno/python/tests/test_tools.py
  • examples/agno/python/src/honcho_agno/__init__.py
  • examples/agno/python/src/honcho_agno/tools.py
📚 Learning: 2025-09-25T15:45:13.243Z
Learnt from: Rajat-Ahuja1997
Repo: plastic-labs/honcho PR: 216
File: src/deriver/queue_manager.py:10-10
Timestamp: 2025-09-25T15:45:13.243Z
Learning: The nanoid dependency is declared in pyproject.toml for the honcho project, so imports of nanoid should work correctly at runtime.

Applied to files:

  • examples/agno/python/pyproject.toml
📚 Learning: 2025-09-25T15:45:13.243Z
Learnt from: Rajat-Ahuja1997
Repo: plastic-labs/honcho PR: 216
File: src/deriver/queue_manager.py:10-10
Timestamp: 2025-09-25T15:45:13.243Z
Learning: In the honcho project, nanoid>=2.0.0 is properly declared as a dependency in pyproject.toml, so nanoid imports work correctly at runtime.

Applied to files:

  • examples/agno/python/pyproject.toml
📚 Learning: 2025-07-30T19:44:05.982Z
Learnt from: VVoruganti
Repo: plastic-labs/honcho PR: 168
File: src/utils/summarizer.py:10-10
Timestamp: 2025-07-30T19:44:05.982Z
Learning: The Honcho project uses Python 3.11 in Dockerfile and requires Python >=3.10 in pyproject.toml. The project uses typing_extensions for the override decorator which is required for Python < 3.12 compatibility.

Applied to files:

  • examples/agno/python/pyproject.toml
📚 Learning: 2025-05-29T16:27:13.808Z
Learnt from: VVoruganti
Repo: plastic-labs/honcho PR: 115
File: README.md:393-396
Timestamp: 2025-05-29T16:27:13.808Z
Learning: CONTRIBUTING.md exists at the repository root in the Honcho project and contains a comprehensive contributing guide. Automated verification scripts can sometimes fail to detect existing files, so manual verification may be needed when users dispute automated findings.

Applied to files:

  • examples/agno/python/pyproject.toml
🧬 Code graph analysis (2)
examples/agno/python/examples/simple_example.py (1)
src/embedding_client.py (1)
  • model (417-419)
examples/agno/python/src/honcho_agno/__init__.py (1)
examples/agno/python/src/honcho_agno/tools.py (1)
  • HonchoTools (26-188)
🪛 GitHub Actions: Static Analysis
examples/agno/python/pyproject.toml

[warning] 1-1: Deprecated: The tool.uv.dev-dependencies field is deprecated and will be removed in a future release; use dependency-groups.dev instead.

🔇 Additional comments (13)
examples/agno/python/LICENSE (1)

1-661: License file is appropriate.

Standard GNU AGPL v3 license text, consistent with the AGPL-3.0-or-later specification in pyproject.toml.

examples/agno/python/README.md (1)

1-222: Documentation is comprehensive and accurate.

The README provides clear guidance on installation, configuration, tool usage, and multi-peer patterns. The architecture notes correctly emphasize that message saving is handled by orchestration code, not the toolkit, which aligns with the implementation in tools.py.

examples/agno/python/pyproject.toml (1)

51-55: Configuration uses correct modern syntax.

The [dependency-groups] section is the correct approach per PEP 735. The pipeline warning about tool.uv.dev-dependencies appears to be from a different context or stale cache, as this file correctly uses the recommended format.

examples/agno/python/src/honcho_agno/tools.py (3)

1-23: Module setup follows best practices.

Clean imports with proper use of TYPE_CHECKING for runtime-optional type hints, and correct logger configuration using __name__.


56-97: Initialization logic is well-structured.

The constructor correctly handles both pre-configured client injection and internal client creation. UUID generation for session_id provides sensible defaults for single-agent usage while supporting explicit session sharing for multi-peer scenarios.


161-188: Chat tool implementation is correct.

The honcho_chat method properly uses stream=False for synchronous operation and handles empty responses gracefully. Error handling follows the established pattern of returning error strings to the agent.

examples/agno/python/src/honcho_agno/__init__.py (1)

1-55: Package initialization is clean and well-documented.

The module docstring provides a complete working example that demonstrates the orchestration pattern. Version matches pyproject.toml, and __all__ correctly limits the public API to HonchoTools.

examples/agno/python/examples/simple_example.py (2)

1-24: LGTM - Clean setup and environment handling.

The module docstring documents required environment variables, and the walrus operator pattern for mapping LLM_OPENAI_API_KEY to OPENAI_API_KEY is clean.


27-53: LGTM - Clear initialization pattern.

The session ID generation with a prefix and short UUID is readable for demos. The HonchoTools initialization and agent configuration are well-structured with helpful instructions.

examples/agno/python/examples/multi_peer_example.py (1)

36-110: LGTM - Well-documented multi-peer pattern.

The docstring clearly explains the three-peer advisory system. The session sharing via tech_bro_tools.session effectively demonstrates the toolkit's design for multi-peer conversations with cross-observation.

examples/agno/python/examples/multi_tool_example.py (1)

86-124: LGTM - Excellent demonstration of direct tool usage.

The explicit tool calls at the end (lines 104-124) clearly showcase the three available tools and their outputs. This is valuable for users understanding the toolkit's capabilities.

examples/agno/python/tests/test_tools.py (2)

16-22: LGTM - Clean minimal mock fixture.

The fixture provides just enough mocking to avoid network calls while testing the toolkit's structure. This aligns with the stated goal in the docstring.


62-71: LGTM - Good tool registration verification.

The test checks both the presence of expected tools and the exact count, which guards against accidental tool additions or removals.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

- Generate unique session ID with uuid.uuid4() in multi_tool_example.py
  to prevent message accumulation across runs
- Update agno dependency from >=1.4.0 to >=2.3.26

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment on lines 46 to 47
# Add user message via orchestration
honcho_tools.session.add_messages([user_peer.message("I prefer Python over JavaScript")])
Copy link
Collaborator

Choose a reason for hiding this comment

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

if the peer object is only made to tag the messages then I think it's a bit overkill. Can just add a Message directly with json, iirc you just need to have a payload like

{
content: "content",
peer: "peer_name"
}

Can doublecheck the code for that

Comment on lines 52 to 53
# Save assistant response via orchestration
honcho_tools.session.add_messages([honcho_tools.peer.message(str(response.content))])
Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah looking at this would want the way you add messages for any peer to look the same

Comment on lines 143 to 147
```python
insights = honcho_tools.honcho_chat(
query="What programming languages does the user prefer?"
)
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

how does this query know what peer you are talking about?

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.

2 participants