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

Since PraisonAI 1.x (PR #4347), the error message names the supported replacement. If you already pass one of the removed kwargs, the traceback tells you exactly what to change:

text
TypeError: Agent.__init__() got unexpected keyword argument(s): stream, verbose
  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 hint is added only for the two names people reach for most (they are accepted by six sibling classes in PraisonAI, and by CrewAI and LangChain).

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: 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

Removed kwargRuntime behaviourReplacement
verbose=Raises TypeError`output=”silent” \“minimal” \“verbose”`
max_iter=Raises TypeError`execution=”fast” \“balanced” or execution={“max_iter”: N}`
session=Raises 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.

Update verbose= to output= first

Agent(verbose=True) now raises TypeError. Replace it with Agent(output="verbose") before migrating, and prefer output= over the deprecated verbose= on AgentTeam, Process, and Workflow too. This clears the most common breaking change up front.

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