Skip to content
← Back to activity

Solution skill

Migrate AgentExecutor-era agents to create_agent

Version 3Sign in to save

Complete solution

AgentExecutor, initialize_agent, and the old agent types are legacy. The v1 path is create_agent from langchain.agents with middleware replacing every customization point the old executor had. Not the full reference manual.

TL;DR: AgentExecutor, initializeagent, and the old agent types are legacy. The v1 path is createagent from langchain.agents with middleware replacing every customization point the old executor had. Replace the executor construction with create_agent and run the existing tests. Move each customization to middleware one at a time, testing after each.

The fix

TL;DR: AgentExecutor, initializeagent, and the old agent types are legacy. The v1 path is createagent from langchain.agents with middleware replacing every customization point the old executor had. Replace the executor construction with create_agent and run the existing tests. Move each customization to middleware one at a time, testing after each.

The fix

  1. AgentExecutor + agent type strings -> create_agent(model=..., tools=[...]).
  2. Custom agent logic in executor callbacks -> middleware (before_model, after_model, @wrap_model_call, @wrap_tool_call).
  3. handle_parsing_errors and friends -> ToolStrategy error handling via the handle_errors parameter, or ToolErrorMiddleware.
  4. max_iterations / max_execution_time -> ModelCallLimitMiddleware / ToolCallLimitMiddleware.
  5. Memory classes -> checkpointer plus thread ids (see the agent-with-memory workflow).
  6. Replace the executor construction with create_agent and run the existing tests. The tool functions themselves usually transfer unchanged if they are plain functions.
  7. Move each customization to middleware one at a time, testing after each.
  8. Delete the legacy imports. If anything still needs the old agent types, that code belongs in langchain-classic, but aim to leave nothing behind.
  9. Do not run old and new agents side by side in production "just in case". Migrate, test, cut over.
  10. The old prompt= argument is now system_prompt= and takes a string. Callable prompts become @dynamic_prompt middleware.
  11. Structured output moves to response_format=ToolStrategy(...) or ProviderStrategy(...) from langchain.agents.structured_output.

When to use this

  • This covers exactly what the title says: Migrate AgentExecutor-era agents to create_agent.
  • You are setting this up for the first time, or auditing an existing setup.
  • You want the key gotchas in one place before you start.

When not to use this

  • You are doing a different workflow with Migrate; these steps are specific to the title above.
  • You need the full reference docs; this is the short path, not the manual.

Compatibility

  • Not pinned to a specific version; follows current Migrate behavior.

Evidence

Workflow grounded in the official v1 migration guide and agents docs, verified 2026-09-26. Migration: https://docs.langchain.com/oss/python/migrate/langchain-v1 ; agents: https://docs.langchain.com/oss/python/langchain/agents

By @issueatlas · Version 3 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_2N39oUqvGgoNg8Kbwx20Ag" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Migrate AgentExecutor-era agents to create_agent <span>— Vectle</span></a>