fix(examples): phase-3 API alignment for session, memory, output, and execution params (v4.6.52)#1864
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more β On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Caution Review failedFailed to post review comments π WalkthroughWalkthroughThis PR consolidates parameters across 78 example files in the PraisonAI repository to reflect API changes. Examples are updated to pass configurations via nested dictionaries ( ChangesExample Parameter Consolidation
π― 4 (Complex) | β±οΈ ~45 minutes
π₯ Pre-merge checks | β 4 | β 1β Failed checks (1 warning)
β Passed checks (4 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@copilot Do a thorough review of this PR. Read ALL existing reviewer comments above from Qodo, Coderabbit, and Gemini first β incorporate their findings. Review areas:
|
There was a problem hiding this comment.
Code Review
This pull request updates various examples across the repository to use consolidated configuration parameters, standardizing memory, knowledge, and output configurations (such as replacing output="verbose" with verbose=True and nesting session/user IDs under memory). Feedback on these changes highlights a potential NameError in advanced_memory.py due to a missing MemoryConfig import, and suggests using a temporary directory in auto_rag_agent_basic.py to prevent untracked files from polluting the workspace.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| agent_override = Agent( | ||
| instructions="You are a helpful assistant.", | ||
| memory=["redis", {"user_id": "custom_user"}], | ||
| memory=MemoryConfig(backend="redis", user_id="custom_user"), |
There was a problem hiding this comment.
Using MemoryConfig directly here will raise a NameError at runtime because it is not imported in this file. To keep the example simple and avoid adding extra imports, you can use a dictionary configuration instead, which is fully supported and consistent with other examples in this repository.
| memory=MemoryConfig(backend="redis", user_id="custom_user"), | |
| memory={"backend": "redis", "user_id": "custom_user"}, |
| from pathlib import Path | ||
| sample_doc = str(Path(__file__).with_name("sample_doc.txt")) | ||
| with open(sample_doc, "w", encoding="utf-8") as f: |
There was a problem hiding this comment.
Creating the sample document in the same directory as the script will leave an untracked sample_doc.txt file in the repository workspace after running the example. Using tempfile.gettempdir() is a cleaner, cross-platform approach that avoids polluting the workspace.
import tempfile
from pathlib import Path
sample_doc = str(Path(tempfile.gettempdir()) / "sample_doc.txt")
with open(sample_doc, "w", encoding="utf-8") as f:
Greptile SummaryThis PR is phase 3 of a systematic API alignment effort, updating 73 example files to match the v4.6.52
Confidence Score: 4/5Safe to merge; all changes are example/demo files with no production runtime impact All 73 changed files are examples. The fixes are systematic and consistent β duplicate kwargs collapsed, invalid constructor args redirected to their consolidated equivalents. Three minor quality issues exist: advanced_workflow_full_features.py silently drops stream=True because the verbose preset resolves to stream=False; knowledge-agents-task.py creates a file at module load time; and basic_workflow.py passes an unused positional string to run(). None of these affect library behaviour or other callers. examples/consolidated_params/advanced_workflow_full_features.py β the WorkflowOutputConfig removal loses stream semantics worth restoring Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Agent / AgentTeam / AgentFlow constructor] --> B{Parameter category}
B -->|session, db| C["memory={session_id:, db:}"]
B -->|user_id at top level| D["memory={user_id:}"]
B -->|markdown, metrics, verbose| E["output={markdown:, metrics:} or output='verbose'"]
B -->|max_iter| F["execution={max_iter:}"]
B -->|web_search| G["web=True"]
B -->|skills_dirs| H["skills=[...]"]
B -->|policy| I["agent.policy = engine (post-init)"]
B -->|guardrails + max_retries| J["guardrails=GuardrailConfig(validator=fn, max_retries=n)"]
B -->|llm_config| K["llm={model:, ...config keys}"]
B -->|default_llm| L["llm= (renamed field)"]
M[CLI handlers / WorkflowManager.execute_yaml] --> N["verbose=True (bool)"]
O[Agent / AgentFlow] --> P["output='verbose' | 'silent' | dict"]
Reviews (1): Last reviewed commit: "fix(examples): phase-3 API alignment for..." | Re-trigger Greptile |
| ], | ||
| # Workflow-level consolidated params | ||
| output=WorkflowOutputConfig(output="verbose", stream=True), | ||
| output="verbose", |
There was a problem hiding this comment.
The
"verbose" preset resolves to stream=False (see OUTPUT_PRESETS["verbose"] in config/presets.py), so replacing WorkflowOutputConfig(output="verbose", stream=True) with just output="verbose" silently changes the stream setting from True to False. Since this file is named advanced_workflow_full_features.py and meant to demonstrate the full output API, using the config class directly with the correct field names would both fix the TypeError and preserve the intended behaviour.
| output="verbose", | |
| output=WorkflowOutputConfig(verbose=True, stream=True), |
| _sample_path = Path(__file__).with_name("sample_knowledge.txt") | ||
| if not _sample_path.exists(): | ||
| _sample_path.write_text("Mervin Praison is the creator of PraisonAI.\n", encoding="utf-8") | ||
|
|
||
| # Create an agent with knowledge capabilities |
There was a problem hiding this comment.
The
_sample_path.write_text(...) call sits at module level, so the file is created on every import β not just when the script is run directly. Moving it inside the if __name__ == "__main__" block keeps the side-effect scoped to direct execution.
| _sample_path = Path(__file__).with_name("sample_knowledge.txt") | |
| if not _sample_path.exists(): | |
| _sample_path.write_text("Mervin Praison is the creator of PraisonAI.\n", encoding="utf-8") | |
| # Create an agent with knowledge capabilities | |
| _sample_path = Path(__file__).with_name("sample_knowledge.txt") | |
| # Create an agent with knowledge capabilities |
| sys.stdout.reconfigure(encoding="utf-8") | ||
| except Exception: | ||
| pass | ||
| result = workflow.run("AI agents") |
There was a problem hiding this comment.
The task template is
"Write about {{topic}}", which is populated from variables={"topic": "AI agents"} set in the constructor. The positional string "AI agents" passed to run() is stored as all_variables["input"] and is never referenced by any template, making it a dead argument. Calling run() with no argument more clearly documents the intent.
| result = workflow.run("AI agents") | |
| result = workflow.run() |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding. Phase 1: Review per AGENTS.md
Phase 2: FIX Valid Issues Phase 3: Final Verdict |
|
Claude finished @MervinPraison's task ββ View job Final Architecture Review βPhase 1: Architecture Review per AGENTS.md
Phase 2: Fix Valid Issues from Previous Reviewers
Phase 3: Final Verdict β Architecture Review SummaryThis PR PASSES all AGENTS.md architectural requirements: β Protocol-Driven Design
β Backward Compatibility
β Performance Impact
β Agent-Centric Design
Code Quality Issues FixedI addressed 4 valid issues identified by previous reviewers:
All fixes have been tested for compilation and pushed to the branch. β RECOMMENDATION: APPROVE AND MERGEThis PR successfully:
Ready for merge π |
8536325
into
MervinPraison:example-validation-phase2
PR stack (read first)
example-validation-phase2(PR #1859)Summary
Phase-3 follow-up to PR #1859 and PR #1855.
Full validation of 796 Python examples (v4.6.52, Windows) produced 197 FAIL. PRs #1855/#1859 fixed 62 files. This PR fixes 22 additional examples with confirmed
TypeError/ deprecated-kwarg failures from the E2E run.API version rule (v4.6.52):
output="verbose"|output="silent"|output={"markdown": True}(consolidatedoutput=API)verbose=True(boolean β notoutput=)session_id=,db=,markdown=,max_iter=,web_search=,skills_dirs=,policy=onAgent.__init__Validation context
Results source:
praison_phase2_e2e.pyrun on PraisonAI 4.6.52 / praisonaiagents 1.6.52.Files changed (22) β error β fix
1.
examples/python/session/session_persistence_example.pyError (Γ3):
Fix:
session_id=βmemory={"session_id": session_id}2.
examples/middleware/injected_state.pyError:
Fix:
session_id="my-session-123"βmemory={"session_id": "my-session-123"}3β6. Managed persistence agents (4 files)
Files:
examples/managed-agents/persistence/neon_managed.pyexamples/managed-agents/persistence/cockroachdb_managed.pyexamples/managed-agents/persistence/supabase_direct_managed.pyexamples/managed-agents/persistence/turso_managed.pyError:
Fix: Move
db=andsession_id=intomemory={"session_id": ..., "db": {...}}7.
examples/python/camera/camera-continuous.pyError:
Fix:
verbose=0βoutput="silent"(latest AgentTeam output API)8.
examples/python/failover_example.pyError:
Fix:
rate_limit=βrate_limit_rpm=(Γ3 profiles)9.
examples/consolidated_params/advanced_workflow_full_features.pyError:
Fix:
output=WorkflowOutputConfig(output="verbose", stream=True)βoutput="verbose"10.
examples/python/tools/exa-tool/rag_examples/agentic_rag/rag_agent.pyError:
Fix:
markdown=Trueβoutput={"markdown": True}11.
examples/python/models/googlegemini/any-llm-agents-advanced.pyError:
Fix:
markdown=Trueβoutput={"markdown": True}12β13.
examples/python/concepts/repetitive-agents.py,examples/python/data/cot-agents.pyError:
Fix:
max_iter=30βexecution={"max_iter": 30}14.
examples/retrieval/basic_retrieval.pyError:
Fix: Merge into
knowledge={"sources": [...], "config": {...}}15.
examples/skills/basic_skill_usage.pyError:
Fix:
skills_dirs=["./"]βskills=["./"]16.
examples/policy/basic_policy.pyError:
Fix: Create agent, then
agent.policy = engine(policy is a property, not ctor kwarg)17.
examples/python/guardrails/production-guardrails-patterns.pyError:
Fix:
guardrails=fn, max_retries=3βguardrails=GuardrailConfig(validator=fn, max_retries=3)18.
examples/python/linear_agent_example.pyError:
Fix:
web_search=Trueβweb=True19.
examples/middleware/configurable_model.pyError:
Fix:
llm="...", llm_config={...}βllm={"model": "...", "configurable": True}20.
examples/yaml/workflows/example_usage.pyError:
Fix:
output="verbose"βverbose=True(handler method uses boolean)21.
examples/python/workflows/workflow_mixed_steps.pyError:
Fix:
default_llm=βllm=(renamed in AgentFlow dataclass)22.
examples/python/custom_tools/example_latency_tracking.pyError:
Fix: Remove invalid
request_id=fromTrackedAgent(...)ctor (tracking via tool, not Agent kwarg)Not in this PR (remaining FAILs β future work)
agent_id,on_task_start,AgentFlow(config=),enable_telemetry(backend=), etc.acp,streamlit,e2b, etc.Test plan
python -m py_compileon all 22 changed filesOPENAI_API_KEYtest-windows) passes on PRresults.jsonlcommitted