Skip to content

[AAASM-3539] ✨ (adapters): Add Smolagents framework adapter#161

Merged
Chisanan232 merged 9 commits into
masterfrom
v0.0.1/AAASM-3539/feat/smolagents_support
Jun 22, 2026
Merged

[AAASM-3539] ✨ (adapters): Add Smolagents framework adapter#161
Chisanan232 merged 9 commits into
masterfrom
v0.0.1/AAASM-3539/feat/smolagents_support

Conversation

@Chisanan232

Copy link
Copy Markdown
Contributor

Description

Adds full Python SDK governance support for Smolagents (Hugging Face; pip smolagents).

The hook point is smolagents.tools.Tool.__call__ — the single chokepoint every tool execution flows through. Both agent paths reach it: ToolCallingAgent via MultiStepAgent.execute_tool_call (tool(...)), and CodeAgent via the sandbox namespace (tools are plain callables, dispatching to Tool.__call__). __call__ runs self.forward(*args, **kwargs), so wrapping it lets governance observe the tool name + arguments and decide before the body runs.

This is genuine governance, not a no-op (AAASM-3528 lesson): a deny verdict short-circuits before forward() executes (fail-closed under enforce), and allow runs the tool then records the result. The plumbing (_normalize_decision, fail-closed posture, block/approval messages, pending-approval flow) is reused from the proven CrewAI adapter.

Type of Change

  • ✨ New feature

Breaking Changes

  • No

Related Issues

  • Related JIRA ticket: AAASM-3539 (parent AAASM-3535)

Testing

  • Unit tests added/updated — test/unit/adapters/smolagents/ (apply/revert idempotency, deny blocks body, allow runs+records, sanitize-flag exclusion, dict-positional arg flattening, adapter contract, no-op negative control).
  • Integration tests added/updated — test/integration/smolagents/test_real_tool_governance.py drives a genuine smolagents.Tool subclass: deny blocks forward(), allow runs+records, plus a post-revert negative control proving the interception is real.
  • smolagents>=1.0.0,<2.0.0 added to the test dependency group so CI exercises the real framework instead of skipping.
  • Validated locally: pytest (302 adapter tests pass incl. the real-framework smoke), ruff check (new files clean), mypy agent_assembly (clean), full pre-commit run (isort/autoflake/black/mypy) green.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Comments added for complex logic
  • Documentation updated (README + docs/compatibility/frameworks.md)
  • All tests passing

🤖 Generated with Claude Code

Chisanan232 and others added 8 commits June 22, 2026 14:15
smolagents routes every tool execution (ToolCallingAgent and CodeAgent
paths) through smolagents.tools.Tool.__call__ -> self.forward, so wrapping
__call__ is the single chokepoint to govern tool name + args before the
body runs. Reuses the CrewAI decision plumbing; fail-closed under enforce.

Refs AAASM-3539

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Implements the FrameworkAdapter contract for smolagents: framework name,
supported range >=1.0.0,<2.0.0 (the 1.x Tool.__call__ chokepoint), and
register/unregister delegating to SmolagentsPatch.

Refs AAASM-3539

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds the smolagents priority (6, before the MCP fallback) and wires the
adapter into the builtin registry so init_assembly() auto-detects it.

Refs AAASM-3539

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dev/test-only (NOT a runtime dependency). Installing smolagents lets the
importorskip-guarded adapter tests drive a real Tool subclass, so a
regression to a fail-open no-op patch is caught instead of silently
skipped (AAASM-3528 lesson).

Refs AAASM-3539

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Covers apply/revert idempotency, deny blocks the tool body, allow runs +
records, sanitize-flag exclusion, dict-positional arg flattening, the
adapter contract, and a no-op negative control that fails if the patch is
ever reduced to a no-op.

Refs AAASM-3539

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drives a genuine smolagents.Tool subclass through Tool.__call__ exactly as
the agent runner does: deny blocks forward(), allow runs + records. Includes
a post-revert negative control proving the interception is real, not no-op.

Refs AAASM-3539

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Refs AAASM-3539

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds the smolagents row to the README and the authoritative Python
framework-compatibility matrix (range >=1.0.0,<2.0.0, tested 1.26.x).

Refs AAASM-3539

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.65517% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
agent_assembly/adapters/smolagents/patch.py 87.36% 12 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread test/unit/adapters/smolagents/test_patch.py Dismissed
Comment thread test/unit/adapters/smolagents/test_patch.py Dismissed
Comment thread test/unit/adapters/smolagents/test_patch.py Dismissed
Comment thread test/unit/adapters/smolagents/test_patch.py Dismissed
Comment thread test/unit/adapters/smolagents/test_patch.py Dismissed
@Chisanan232

Copy link
Copy Markdown
Contributor Author

Claude Code — review result

✅ Real CI green (SonarCloud not blocking).

  • Adapter: hooks smolagents.tools.Tool.__call__ (verified against smolagents==1.26.0; both ToolCallingAgent and CodeAgent reach it). Registered (priority 6), get_supported_versions() = >=1.0.0,<2.0.0.
  • Governance proven: tests run against a genuine smolagents.Tool (added to the test dep group so CI exercises the real framework) — deny blocks forward, allow runs+records, post-revert negative control. ✔
  • Shared files: trivial keep-all overlap with siblings. This is the only PR touching test_registry.py, and it uses membership assertions (not an exact count) → no count-bump trap when all 5 land.

Ready to merge. Merge before examples #150 + a python-sdk release. Full cross-repo review on AAASM-3535.

Resolve the registry + README overlaps after py #160 (Haystack) merged:
keep both the Haystack (now on master) and Smolagents registry entries,
adapter imports, builtin-list entries, and the combined README adapter
list. frameworks.md auto-merged (both rows present).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@Chisanan232 Chisanan232 merged commit 7181dc6 into master Jun 22, 2026
26 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/AAASM-3539/feat/smolagents_support branch June 22, 2026 08:09
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