Skip to content

mouadja02/skills / skills/agent-design/smolagents-code-agents

smolagents-code-agents

Verified

Use when building Hugging Face smolagents, code-executing agents, Python-action agents, Hub-shared tools, or lightweight agent prototypes that need sandboxing and provider flexibility.

Smolagents Code Agents

Use code actions when an agent benefits from loops, variables, data transforms, and multi-call tool composition. Treat generated code as untrusted unless it runs in a real sandbox.

Use When

  • The user wants a lightweight agent prototype in Python.
  • Tool calls need loops, branching, or batching.
  • The agent should use Hugging Face Inference Providers, LiteLLM, OpenAI-compatible servers, local transformers, or Ollama.
  • The agent needs MCP tools, Hub tools, or a shared Space.
  • You must decide between CodeAgent and ToolCallingAgent.

Build Pattern

  1. Choose CodeAgent when actions need Python control flow; choose ToolCallingAgent for simple structured tool calls.
  2. Keep tools small, typed, and side-effect explicit.
  3. Configure the model through environment variables or a provider object, never hard-code secrets.
  4. Run code execution in Docker, E2B, Modal, Blaxel, or another isolation boundary.
  5. Allow imports by explicit whitelist only.
  6. Stream logs and capture intermediate observations for debugging.
  7. Add a task-level timeout and max-step budget.

Safety Baseline

Never treat LocalPythonExecutor as a security boundary for untrusted code. Use it only for trusted local experiments.

Generate a starter safety scaffold:

python scripts/smolagent_safety_scaffold.py --name research_agent

Review sandboxing-checklist.md before running any agent that executes model-written code.

Quick Selection

RequirementChoose
Agent writes Python actionsCodeAgent
Strict JSON-like tool callsToolCallingAgent
Untrusted tasks or web dataSandboxed executor
Local model experimentsTransformersModel or Ollama-compatible provider
Hosted provider flexibilityInferenceClientModel, LiteLLMModel, or OpenAI-compatible model

Common Mistakes

MistakeFix
Running untrusted code locallyUse Docker or managed sandbox
Exposing broad filesystem accessMount a temporary workspace only
Giving tools vague docstringsMake inputs, outputs, and side effects explicit
Letting agents import anythingWhitelist imports per task
Shipping without trace logsPersist steps, code snippets, tool outputs, and final answer

References

reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 467kUpdated Claude CodeCodexVerifiedInstall
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 467kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 319kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 319kUpdated Claude CodeCodexVerifiedInstall