Skip to content

feat: add SmolAgents integration with Hindsight memory tools#658

Merged
nicoloboschi merged 4 commits intomainfrom
feat/smolagents-integration
Apr 29, 2026
Merged

feat: add SmolAgents integration with Hindsight memory tools#658
nicoloboschi merged 4 commits intomainfrom
feat/smolagents-integration

Conversation

@benfrank241
Copy link
Copy Markdown
Contributor

Summary

  • Adds hindsight-smolagents package under hindsight-integrations/smolagents/
  • Three native SmolAgents Tool subclasses: HindsightRetainTool, HindsightRecallTool, HindsightReflectTool
  • create_hindsight_tools() factory and memory_instructions() helper for system prompt injection
  • 81 unit tests, lint clean
  • Docs page, sidebar entry, integrations grid entry, and HuggingFace icon

Design notes

  • bank_id is baked in at construction time (SmolAgents has no RunContext equivalent)
  • Sync forward() methods call the Hindsight Python client directly
  • Follows the same config/error/tools module pattern as hindsight-agno

Test plan

  • cd hindsight-integrations/smolagents && uv run pytest tests/ -v — all 81 tests pass
  • uv run ruff check . && uv run ruff format --check . — lint clean
  • Manual end-to-end: start API, retain/recall/reflect against a live bank
  • Docs page renders and icon displays in integrations grid
  • ./scripts/release-integration.sh smolagents recognizes the integration name

@benfrank241 benfrank241 force-pushed the feat/smolagents-integration branch from b8057b3 to 1fb827b Compare April 27, 2026 15:15
@benfrank241 benfrank241 marked this pull request as ready for review April 27, 2026 18:29
benfrank241 and others added 4 commits April 29, 2026 10:58
Adds hindsight-integrations/smolagents with retain, recall, and reflect tools
for HuggingFace SmolAgents.

- hindsight_smolagents/: config, errors, and tools (retain/recall/reflect, plus
  memory_instructions helper for prompt-time injection)
- 81 unit tests (all passing)
- Docs page at hindsight-docs/docs-integrations/smolagents.md
- Icon at hindsight-docs/static/img/icons/smolagents.png
- Entry in integrations.json so it appears on the listing page
- CI workflow job test-smolagents-integration
- Wired into scripts/release-integration.sh VALID_INTEGRATIONS

Replaces the earlier draft commits (originally opened March 23) with a clean
single commit rebased on latest main, dropping unrelated package-lock.json
changes that had been bundled in by mistake.
build-docs CI requires every integration page to have both 'title' and
'description' in its frontmatter. Without them, check-integration-seo.mjs
fails the docusaurus build.
- Add smolagents to the INTEGRATIONS table in generate_changelog.py so
  the release script can cut a tag (release-integration.sh already had
  it after the rebase, but the changelog generator needs its own entry).
- Add a sidebar link in hindsight-docs/sidebars.ts so the docs page is
  reachable from navigation, matching the agentcore pattern.
- examples/interactive_test.py: import-order + drop f-prefix on a
  no-placeholder f-string (ruff F541, I001).
- ruff format adjustments in tools.py.
@nicoloboschi nicoloboschi force-pushed the feat/smolagents-integration branch from 074f17a to fff3134 Compare April 29, 2026 09:00
@nicoloboschi
Copy link
Copy Markdown
Collaborator

Force-pushed a rebase + review fixes (was 074f17a, now fff3134).

Rebased onto current main and resolved three conflicts (scripts/release-integration.sh, hindsight-docs/src/data/integrations.json, .github/workflows/test.yml) — the older merge commit 074f17ac is gone. Branch is now 4 commits ahead of main: the original three plus one follow-up.

Fixes applied (commit fff31345):

  • Added smolagents to the consolidated INTEGRATIONS table in hindsight-dev/hindsight_dev/generate_changelog.py. Without this the release script aborts at the changelog-generation step (this was originally three parallel lists; refactor(release): single integration table in generate_changelog #1314 collapsed them into one, but the new integration still needs an entry).
  • Added a sidebar link in hindsight-docs/sidebars.ts. The docs page existed but wasn't reachable from navigation.
  • examples/interactive_test.py: ruff F541 (f"" with no placeholders) and I001 (import order).
  • ruff format unwrapped a few paren-wrapped expressions in tools.py.

Verified locally: uv run pytest tests -q → 81 passed, ruff check/ruff format --check → clean.

Things I left for you to decide (not blocking, but worth a thought):

  • HindsightRetainTool._ensure_bank (tools.py:85-93) catches every exception during create_bank and still adds the bank to _created_banks — auth/network failures get silently filed away, then retain proceeds against a bank that may not exist. Maybe narrow the catch to "already exists" cases?
  • memory_instructions returns "" on any exception (tools.py:371-373). Comment says "shouldn't block the agent" — fair, but it also swallows e.g. AttributeErrors during refactors. A logger.warning(..., exc_info=True) would help.
  • Sync Hindsight client inside SmolAgents Tool.forward is reasonable since SmolAgents is sync top-level, but the sync wrapper uses loop.run_until_complete and will raise if the agent is ever invoked from inside a running event loop (FastAPI handler, etc.). Worth a note in the docs or README.

@nicoloboschi nicoloboschi merged commit 8314de5 into main Apr 29, 2026
114 of 118 checks passed
@nicoloboschi nicoloboschi deleted the feat/smolagents-integration branch April 29, 2026 09:37
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