Skip to content

Commit 9d05274

Browse files
fix: address critical deprecation and doctor fix issues
- Remove duplicate deprecation warnings between wrapper and core Agent - Fix CLI command reference from 'praisonai doctor --fix' to 'praisonai doctor fix --execute' - Remove unimplemented 'allow_legacy_runtime_pin=True' reference - Fix duplicate file processing in doctor handler by deduplicating yaml_files - Add proper error handling with exit codes in doctor fix command - Remove unused imports and variables in doctor handler - Fix CLI flag mapping from --config to --file for handler compatibility - Remove test fixture from repository root These fixes address all critical bugs identified by previous reviewers. Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
1 parent f132b7f commit 9d05274

5 files changed

Lines changed: 8 additions & 33 deletions

File tree

ā€Žsrc/praisonai-agents/praisonaiagents/agent/agent.pyā€Ž

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,8 +2041,7 @@ def __init__(
20412041
warnings.warn(
20422042
"Agent-level 'cli_backend' parameter is deprecated when model configuration is available. "
20432043
"Consider using model-scoped runtime configuration instead. "
2044-
"Use 'allow_legacy_runtime_pin=True' to suppress this warning. "
2045-
"For migration assistance, run: praisonai doctor --fix",
2044+
"For migration assistance, run: praisonai doctor fix --execute",
20462045
DeprecationWarning,
20472046
stacklevel=2
20482047
)

ā€Žsrc/praisonai/praisonai/agent.pyā€Ž

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,7 @@ def __init__(self, *args, cli_backend: Optional[Union[str, Any]] = None, **kwarg
3030
- None: No CLI backend
3131
**kwargs: Keyword arguments for core Agent
3232
"""
33-
# Check for deprecation warning in wrapper layer
34-
if cli_backend is not None:
35-
# Check if model/llm is specified in kwargs
36-
if 'model' in kwargs or 'llm' in kwargs:
37-
import warnings
38-
warnings.warn(
39-
"Agent-level 'cli_backend' parameter is deprecated when model configuration is available. "
40-
"Consider using model-scoped runtime configuration instead. "
41-
"Use 'allow_legacy_runtime_pin=True' to suppress this warning. "
42-
"For migration assistance, run: praisonai doctor --fix",
43-
DeprecationWarning,
44-
stacklevel=2
45-
)
46-
33+
# Deprecation warning will be emitted by the core Agent class
4734
# Resolve CLI backend configuration using unified resolver
4835
if cli_backend is not None and not self._is_protocol_instance(cli_backend):
4936
from .cli_backends import resolve_cli_backend_config

ā€Žsrc/praisonai/praisonai/cli/commands/doctor.pyā€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def doctor_fix(
356356
if not backup:
357357
args.append("--no-backup")
358358
if config_path:
359-
args.extend(["--config", config_path])
359+
args.extend(["--file", config_path])
360360
raise typer.Exit(_run_doctor(args))
361361

362362

ā€Žsrc/praisonai/praisonai/cli/features/doctor/handler.pyā€Ž

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ def _run_fix_mode(self, config: DoctorConfig) -> int:
315315
import os
316316
import yaml
317317
import glob
318-
from pathlib import Path
319318

320319
if not config.quiet:
321320
print("šŸ”§ PraisonAI Configuration Migration Tool")
@@ -330,6 +329,7 @@ def _run_fix_mode(self, config: DoctorConfig) -> int:
330329
patterns = ["*.yaml", "*.yml", "agents.yaml", "config.yaml"]
331330
for pattern in patterns:
332331
yaml_files.extend(glob.glob(pattern))
332+
yaml_files = list(dict.fromkeys(yaml_files)) # Remove duplicates while preserving order
333333

334334
if not yaml_files:
335335
if not config.quiet:
@@ -338,6 +338,7 @@ def _run_fix_mode(self, config: DoctorConfig) -> int:
338338

339339
issues_found = 0
340340
files_modified = 0
341+
files_failed = 0
341342

342343
for yaml_file in yaml_files:
343344
if not os.path.exists(yaml_file):
@@ -348,7 +349,6 @@ def _run_fix_mode(self, config: DoctorConfig) -> int:
348349
data = yaml.safe_load(f)
349350

350351
# Check for deprecated cli_backend usage
351-
modified = False
352352
if self._has_deprecated_cli_backend(data):
353353
issues_found += 1
354354
if not config.quiet:
@@ -375,9 +375,10 @@ def _run_fix_mode(self, config: DoctorConfig) -> int:
375375
print(f"āœ… Migrated: {yaml_file}")
376376
else:
377377
if not config.quiet:
378-
print(f" Run with --execute to apply migration")
378+
print(" Run with --execute to apply migration")
379379

380380
except Exception as e:
381+
files_failed += 1
381382
if not config.quiet:
382383
print(f"āŒ Error processing {yaml_file}: {e}")
383384

@@ -391,7 +392,7 @@ def _run_fix_mode(self, config: DoctorConfig) -> int:
391392
if not config.execute and issues_found > 0:
392393
print("\nšŸ’” To apply migrations, run: praisonai doctor fix --execute")
393394

394-
return 0
395+
return 1 if files_failed > 0 else 0
395396

396397
def _has_deprecated_cli_backend(self, data: dict) -> bool:
397398
"""Check if YAML config has deprecated cli_backend usage."""

ā€Žtest_config.yamlā€Ž

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
Ā (0)
⚔