Code Migration

AI-powered migration of your agent code to PraisonAI

Migrate your existing agent projects to PraisonAI using an AI-driven workflow that analyzes, converts, and validates your codebase automatically.

python
from praisonaiagents import Agent

agent = Agent(name="migration-helper", instructions="Help migrate from older PraisonAI versions.")
agent.start("Migrate my agents.yaml from v1 format to v2 format.")
Diagram

Migration Pipeline

fail

pass

📥 Source Project

🔍 Analyzer

🪄 Converter

✅ Evaluator

⚠️ Error Agent

📤 PraisonAI Project

How It Works

The user points the CLI at a project; AgentFlow runs four agents in sequence — Analyzer reads the codebase, Converter transforms it, Evaluator scores the result (1–10), and Error Agent diagnoses failures and retries up to 3 times.

Diagram
EvaluatorConverterAnalyzerUserEvaluatorConverterAnalyzerUsermigrate ./projectMapped agent definitionsConverted codeRetry if score < 8PraisonAI project (score ≥ 8)
AgentRole
AnalyzerReads all files, maps agent definitions, task dependencies, and import structures
ConverterTransforms code using a feature spec that maps source patterns to PraisonAI equivalents
EvaluatorLLM-as-Judge scoring — a score of 8+ means successful migration
Error AgentDiagnoses evaluation failures and feeds corrections back to the Converter

Quick Start

  1. Point to Your Project
    bash
    praisonai migrate ./my-agent-project
  2. AI Analyzes All Files

    The Analyzer Agent reads your entire codebase to understand relationships between files.

  3. Intelligent Conversion

    The Converter Agent transforms your code using learned patterns.

  4. Automatic Validation

    The Evaluator Agent tests the converted code. If issues are found, the Error Agent analyzes and retries (up to 3 times).

The Migration Agents

CLI Reference

bash
praisonai migrate <path> [options]
path string

Path to file or directory to migrate

–output string

Output directory for converted files

–apply flag

Apply changes (default is dry-run preview)

–max-retries integer

Maximum retry attempts on evaluation failure

Feature Mapping

The migration uses a feature specification to map patterns:

Agent Parameters
Source PatternPraisonAI Equivalent
agent = CrewAgent(role=...)agent = Agent(name=..., role=...)
@tool decoratortools=[function_name]
Task(description=...)Task(description=..., agent=agent)
Crew(agents=..., tasks=...)AgentTeam(agents=..., tasks=...) — PraisonAIAgents also works as a silent alias, see Back-compat class aliases

Evaluation Loop

Diagram

Score >= 8

Score < 8

Yes

No

Convert

Evaluate

✅ Success

Error Analysis

Retry < 3?

❌ Manual Review

Programmatic API

python
from praisonai.cli.features.migrate import MigrationFlow

# Create migration flow
flow = MigrationFlow(
    source_path="./my-project",
    output_path="./converted",
    max_retries=3
)

# Run the agent-driven migration
result = flow.run()

if result.success:
    print(f"Migration complete: {result.files_converted} files")
else:
    print(f"Issues found: {result.errors}")

Migration Tips

Troubleshooting

Migration keeps retrying

The Evaluator may be finding issues. Check the error analysis output for specific problems. You may need to manually adjust complex patterns.

Some files not converted

Files without recognizable agent patterns are skipped. The Analyzer Agent only processes files with detectable patterns.

Import errors after migration

Ensure you have praisonaiagents installed. Some source-specific tools may need manual replacement.


API Migration: verbose= to output=

The verbose= parameter has been consolidated into the output= parameter across all PraisonAI components.

Diagram

✅ New API

❌ Old API

TypeError → Rejected

TypeError → Rejected

Agent(verbose=True)

AgentTeam(verbose=True)

Agent(output=’verbose’)

AgentTeam(output=’verbose’)

Quick Migration

Agent

python
# ❌ Old (raises TypeError)
agent = Agent(instructions="...", verbose=True)

# ✅ New
agent = Agent(instructions="...", output="verbose")

AgentTeam

python
# ❌ Old (raises TypeError)
team = AgentTeam(agents=[...], tasks=[...], verbose=True)

# ✅ New
team = AgentTeam(agents=[...], tasks=[...], output="verbose")

Process

python
# ⚠️ Old (still works, backward compat)
process = Process(tasks={...}, agents=[...], verbose=True)

# ✅ New (preferred)
process = Process(tasks={...}, agents=[...], output="verbose")

What the error looks like

Every removed Agent kwarg gets one hint line in the error, and that line names its replacement (PraisonAI PR #4347 for verbose= / stream=, PR #6555 for the other 11). The traceback tells you exactly what to change:

text
TypeError: Agent.__init__() got unexpected keyword argument(s): max_iter, stream, verbose
  max_iter: moved into execution=; use execution=ExecutionConfig(max_iter=...).
  stream: streaming moved into output=; use output=OutputConfig(stream=True).
  verbose: verbosity moved into output=; use output='verbose' (or output=OutputConfig(verbose=True)).

Unknown kwargs are still rejected outright rather than silently swallowed. This is intentional, so a typo can never disable the behaviour it was meant to configure. The parameters stay removed. See Removed Agent kwargs for all 13 names.

Output Presets

PresetDescription
"silent"No output (default)
"verbose"Rich panels with markdown
"status"Tool calls + response
"trace"Full trace with timestamps
"stream"Real-time token streaming
"json"JSONL events

Component Status

Componentverbose=output=Notes
Agent❌ Rejected✅ RequiredUse output="verbose"
AgentTeam❌ Rejected✅ RequiredRaises TypeError — use output="verbose"
Process⚠️ Backward compat✅ PreferredBoth work, prefer output=
Workflow⚠️ Internal only✅ PreferredUse output= in constructor
Eval✅ IntentionalN/AKeep verbose= for eval logging

API Migration: removed Agent kwargs

Thirteen flat Agent(...) kwargs were grouped into config objects. Each one now raises TypeError with a hint that names its replacement.

python
from praisonaiagents import Agent
from praisonaiagents.config import OutputConfig, ExecutionConfig

# ❌ Old (all raise TypeError on the current SDK):
# agent = Agent(name="Researcher", verbose=True, markdown=True, stream=True,
#               self_reflect=True, max_iter=10, cache=True, web_search=True,
#               temperature=0.2, max_tokens=500)

# ✅ New — grouped into config objects; temperature/max_tokens live on the model
agent = Agent(
    name="Researcher",
    instructions="Research and summarise",
    output=OutputConfig(verbose=True, markdown=True, stream=True),
    reflection=True,
    execution=ExecutionConfig(max_iter=10),
    caching=True,
    web=True,
    model={"model": "gpt-4o-mini", "temperature": 0.2, "max_tokens": 500},
)
agent.start("Compare GPT-4o-mini and Claude Haiku on a short brief.")

Reflection

python
from praisonaiagents import Agent
from praisonaiagents.config import ReflectionConfig

# ❌ Old (raises TypeError)
# agent = Agent(name="Writer", self_reflect=True, max_reflect=3, min_reflect=1)

# ✅ New
agent = Agent(
    name="Writer",
    reflection=ReflectionConfig(min_iterations=1, max_iterations=3),
)

Model settings

python
from praisonaiagents import Agent

# ❌ Old (raises TypeError)
# agent = Agent(name="Writer", temperature=0.2, max_tokens=50)

# ✅ New — set them on the model
agent = Agent(
    name="Writer",
    model={"model": "gpt-4o-mini", "temperature": 0.2, "max_tokens": 50},
)

max_iter

python
from praisonaiagents import Agent
from praisonaiagents.config import ExecutionConfig

# ❌ Old (raises TypeError)
# agent = Agent(name="Worker", max_iter=10)

# ✅ New
agent = Agent(name="Worker", execution=ExecutionConfig(max_iter=10))

cache / web_search

python
from praisonaiagents import Agent
from praisonaiagents.config import WebConfig

# ❌ Old (raises TypeError)
# agent = Agent(name="Searcher", cache=True, web_search=True)

# ✅ New
agent = Agent(name="Searcher", caching=True, web=True)

# Explicit form. web=True already leaves fetch off on non-Claude models (fetch is Claude-only)
agent = Agent(
    name="Searcher",
    model="gpt-4o-mini",
    web=WebConfig(search=True, fetch=False),
)

system_template

python
from praisonaiagents import Agent
from praisonaiagents.config import TemplateConfig

# ❌ Old (raises TypeError)
# agent = Agent(name="Helper", system_template="You are {{role}}.")

# ✅ New
agent = Agent(name="Helper", templates=TemplateConfig(system="You are {{role}}."))

The full list of names is in Removed kwargs at a glance.

API Migration: max_iter= / session=

AgentTeam also removed the max_iter= and session= kwargs. Both now raise TypeError — use execution= for iteration limits and variables= for session state.

Diagram

✅ New API

❌ Old API

TypeError → Rejected

TypeError → Rejected

AgentTeam(max_iter=20)

AgentTeam(session=obj)

AgentTeam(execution=’balanced’)

AgentTeam(variables={…})

max_iter= → execution=

Replace max_iter= with an execution= preset ("fast" sets max_iter=10, "balanced" sets max_iter=20) or pass an explicit value.

Preset

python
from praisonaiagents import Agent, Task, AgentTeam

# ❌ Old (raises TypeError)
# team = AgentTeam(agents=[...], tasks=[...], max_iter=20)

# ✅ New — preset ("fast"=10 | "balanced"=20)
team = AgentTeam(
    agents=[Agent(name="Analyst", instructions="Analyse the input")],
    tasks=[Task(description="Analyse Q3 metrics", expected_output="Insights")],
    execution="balanced",
)
team.start()

Explicit max_iter

python
from praisonaiagents import Agent, Task, AgentTeam

# ❌ Old (raises TypeError)
# team = AgentTeam(agents=[...], tasks=[...], max_iter=30)

# ✅ New — explicit value via dict
team = AgentTeam(
    agents=[Agent(name="Analyst", instructions="Analyse the input")],
    tasks=[Task(description="Analyse Q3 metrics", expected_output="Insights")],
    execution={"max_iter": 30},
)
team.start()

session= → variables=

The session= kwarg is gone. Pass session state through variables= and call session.save() explicitly.

python
from praisonaiagents import Agent, Task, AgentTeam

# ❌ Old (raises TypeError)
# team = AgentTeam(agents=[...], tasks=[...], session=my_session)

# ✅ New — session state via variables=
team = AgentTeam(
    agents=[Agent(name="Writer", instructions="Personalise the response")],
    tasks=[Task(description="Greet {{user}} about {{topic}}", expected_output="Message")],
    variables={"user": "Alice", "topic": "PraisonAI"},
)
team.start()

# Persist session state explicitly when you need it
# my_session.save()

Removed kwargs at a glance

TargetRemoved kwargRuntime behaviourReplacement
Agentverbose=TypeError + hintoutput="verbose" or output=OutputConfig(verbose=True)
Agentmarkdown=TypeError + hintoutput=OutputConfig(markdown=True)
Agentstream=TypeError + hintoutput=OutputConfig(stream=True)
Agentmetrics=TypeError + hintoutput=OutputConfig(metrics=True)
Agentself_reflect=TypeError + hintreflection=True or reflection=ReflectionConfig(...)
Agentmax_reflect=TypeError + hintreflection=ReflectionConfig(max_iterations=...)
Agentmin_reflect=TypeError + hintreflection=ReflectionConfig(min_iterations=...)
Agentsystem_template=TypeError + hinttemplates=TemplateConfig(system=...)
Agentcache=TypeError + hintcaching=True / False or caching=CachingConfig(enabled=...)
Agentweb_search=TypeError + hintweb=True or web=WebConfig(search=True, fetch=False)
Agentmax_iter=TypeError + hintexecution=ExecutionConfig(max_iter=...)
Agenttemperature=TypeError + hintmodel={"model": "...", "temperature": ...} or chat(temperature=...)
Agentmax_tokens=TypeError + hintmodel={"model": "...", "max_tokens": ...}
AgentTeamverbose=TypeError`output=”silent” \“minimal” \“verbose”`
AgentTeammax_iter=TypeError`execution=”fast” \“balanced” or execution={“max_iter”: N}`
AgentTeamsession=TypeErrorvariables={...} + session.save()

Back-compat class aliases

AgentTeam is the canonical multi-agent class in v1.0+. The SDK also exposes three silent aliases that resolve to the same class, so old snippets, older docs, and downstream integrations keep working unchanged.

Diagram

praisonaiagents (root)

AgentTeam
canonical

AgentManager

Agents

PraisonAIAgents

All four are importable from the package root and point to the same object:

python
from praisonaiagents import AgentTeam, AgentManager, Agents, PraisonAIAgents

assert AgentTeam is AgentManager is Agents is PraisonAIAgents   # True
NameStatusUse in
AgentTeam✅ Canonical (v1.0+)New code
AgentManager🟰 Silent aliasLegacy integrations
Agents🟰 Silent aliasPre-v1.0 tutorials
PraisonAIAgents🟰 Silent aliasPre-1.0 code, downstream integrations that guard from praisonaiagents import PraisonAIAgents

Best Practices

Migrate a copy, not your working tree

The migration pipeline rewrites source files as it converts patterns. Point it at a clean checkout or branch so you can diff the result and roll back if the Evaluator score is low. Version control makes reviewing the Converter’s changes straightforward.

Trust the 8+ score gate

The Evaluator uses LLM-as-Judge scoring from 1–10 and treats 8+ as a successful migration. Don’t ship a converted project that scores below that threshold — let the Error Agent’s retries (up to 3) run, then review any file the Evaluator still flags.

Fix removed kwargs first

Agent(verbose=True) and the other 12 removed flat kwargs (markdown=, stream=, max_iter=, temperature= and the rest) now raise TypeError. Replace them using Removed kwargs at a glance before migrating, and prefer output= over the deprecated verbose= on AgentTeam, Process, and Workflow too. The error message names the replacement for each one.

Review imports after conversion

The Analyzer maps import structures, but confirm the converted project uses friendly top-level imports (from praisonaiagents import Agent, Task, AgentTeam) and that any custom tools resolve. A quick smoke run catches missed dependencies the Evaluator can’t see.

Related