Skip to content

feat: add AutoGen integration for Hindsight#719

Merged
nicoloboschi merged 5 commits into
mainfrom
feat/autogen-integration
Apr 1, 2026
Merged

feat: add AutoGen integration for Hindsight#719
nicoloboschi merged 5 commits into
mainfrom
feat/autogen-integration

Conversation

@DK09876

@DK09876 DK09876 commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds hindsight-autogen package providing AutoGen FunctionTool instances for persistent long-term memory
  • Factory function create_hindsight_tools() returns retain/recall/reflect tools compatible with AssistantAgent(tools=[...])
  • Async-native — uses aretain/arecall/areflect directly in AutoGen's async runtime
  • Full parameter set: tags, metadata, document_id, recall types, reflect context/schema
  • Global config support via configure() with per-call overrides
  • 31 unit tests, docs page, integrations.json entry

Test plan

  • 31 unit tests pass (uv run pytest tests/ -v)
  • Ruff lint and format clean
  • Manual E2E test with running Hindsight server
  • Cookbook notebook (separate PR in hindsight-cookbook)

🤖 Generated with Claude Code

@DK09876
DK09876 marked this pull request as draft March 26, 2026 21:12
DK09876 and others added 2 commits March 30, 2026 09:37
Adds hindsight-autogen package providing FunctionTool instances that give
AutoGen agents persistent long-term memory via retain/recall/reflect APIs.

- Package: hindsight_autogen with create_hindsight_tools() factory
- 31 unit tests covering tool creation, invocation, config fallback, errors
- Docs page and integrations.json entry
- README with quickstart and configuration reference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix install instructions to include autogen-agentchat and autogen-ext[openai]
- Add autogen.svg icon to prevent broken image in integrations grid
- Change icon reference from .png to .svg in integrations.json

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DK09876
DK09876 force-pushed the feat/autogen-integration branch from a653149 to c2bf3c7 Compare March 30, 2026 16:37
DK09876 and others added 2 commits March 30, 2026 13:54
- Add time.sleep(3) between retain and recall to wait for async processing
- Close Hindsight client and model client to avoid unclosed session warnings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
time.sleep blocks the event loop; asyncio.sleep yields control.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DK09876
DK09876 marked this pull request as ready for review March 30, 2026 21:20

@nicoloboschi nicoloboschi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review

Overall: Clean, well-structured integration with good test coverage. A few issues worth addressing before merge:

Must Fix

1. release-integration.sh needs updating
The release script must be made aware of this new integration so it gets published alongside the others.

2. verbose config field is unused
HindsightAutoGenConfig.verbose is declared but never read by any tool function. Either wire it into the tool logging or remove it.

3. Hardcoded defaults scattered across multiple locations
"mid", 4096, "any" appear as fallback defaults in both config.py and tools.py. If the defaults drift, behavior becomes inconsistent. Centralize them as constants or always require config.

4. No validation on enum-like fields
budget accepts any string — no check that it's low/mid/high. Same for recall_tags_match (any/all/any_strict/all_strict). A typo like "medium" would silently pass through and fail at the API level.

5. asyncio.sleep(3) in docs/README
The Quick Start shows await asyncio.sleep(3) after retain with the comment "Wait for Hindsight to finish processing." This is a fragile magic number — it'll confuse users and fail for larger documents. Either document this limitation clearly or provide a polling helper.

6. Missing ruff config in pyproject.toml
The other Python packages in the repo use ruff with line-length = 120. This package has no [tool.ruff] section, so it'll use ruff defaults (88 chars). Should align with the rest of the monorepo.

Minor / Nits

  • Optional from typing is used alongside native list[str] syntax — pick one style. Since requires-python = ">=3.10", native str | None is fine everywhere.
  • errors.py defines HindsightError but tool functions catch broad Exception and re-wrap — consider catching httpx / client-specific errors instead so programming errors (e.g., TypeError) aren't swallowed.
  • _client.py hardcodes timeout=30.0 — should this be configurable or at least match the default in hindsight-client?
  • No py.typed marker for PEP 561 type checking support.

Looks Good

  • Async-native design matches AutoGen's runtime correctly
  • FunctionTool usage is idiomatic for AutoGen
  • Test coverage is thorough (31 tests covering tools, config fallbacks, error paths)
  • Tool descriptions are clear and will guide LLM tool selection well
  • Selective tool inclusion (include_retain/recall/reflect) is a nice touch
  • Docs page and integrations.json entry included

- Add autogen to VALID_INTEGRATIONS in release-integration.sh
- Remove unused verbose config field
- Extract DEFAULT_BUDGET/MAX_TOKENS/RECALL_TAGS_MATCH constants in config.py,
  import from tools.py to eliminate default duplication
- Add Literal types for budget and recall_tags_match validation
- Modernize type hints to X | None with from __future__ import annotations
- Add [tool.ruff] line-length = 120 to match monorepo convention
- Add py.typed PEP 561 marker
- Re-raise HindsightError before broad Exception catch
- Expand asyncio.sleep(3) comment explaining when/why it's needed
- Remove verbose from docs configure() reference table

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@nicoloboschi nicoloboschi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@nicoloboschi
nicoloboschi merged commit a757765 into main Apr 1, 2026
85 of 90 checks passed
kagura-agent added a commit to kagura-agent/hindsight that referenced this pull request Apr 2, 2026
autogen.md (PR vectorize-io#719) was added after the SEO check (PR vectorize-io#787) without
required title and description frontmatter, causing verify-generated-files
CI to fail on all branches.
kagura-agent added a commit to kagura-agent/hindsight that referenced this pull request Apr 2, 2026
The autogen integration was added to current docs (via PR vectorize-io#719) but
not to the versioned v0.4 docs, causing a broken link from the
/integrations page to /sdks/integrations/autogen during docusaurus build.
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