agentloop-profiler 0.2.4__tar.gz → 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {agentloop_profiler-0.2.4/agentloop_profiler.egg-info → agentloop_profiler-0.2.5}/PKG-INFO +7 -1
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/README.md +6 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/improvement.py +173 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/improvement_cli.py +78 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/improvement_report.py +4 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/version.py +1 -1
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5/agentloop_profiler.egg-info}/PKG-INFO +7 -1
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop_profiler.egg-info/SOURCES.txt +1 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/pyproject.toml +1 -1
- agentloop_profiler-0.2.5/tests/test_claude_code_runner.py +287 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_dashboard_input_validation.py +6 -5
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_dashboard_quality.py +2 -1
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_dashboard_semantic_waste.py +3 -1
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_dashboard_structured_quality.py +3 -1
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_dashboard_workflows.py +3 -1
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_improvement.py +156 -2
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/LICENSE +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/THIRD_PARTY_LICENSES.md +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/__init__.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/ablation_protocol.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/ablations.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/aggregate_cli.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/aggregate_stats.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/aggregates.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/audit.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/autoinstrument.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/batch_experiments.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/batching.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/budget_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/budgets.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/calibration.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/checkpoint_state.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/checkpoint_store.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/ci.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/cli.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/cli_paths.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/client.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/completion.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/completion_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/config.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/context_controls.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/context_experiments.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/context_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/costs.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/cursor_validation.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/decorators.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/demo.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/doctor.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/drift.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/drift_cli.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/drift_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/drift_windows.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/entrypoint.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/estimates.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/events.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/experiment_artifacts.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/experiment_observations.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/experiment_reports.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/experiment_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/experiments.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/exporters.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/finding_benchmark_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/finding_benchmarks.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/findings.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/graph.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/harness.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/harness_bench/__init__.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/harness_bench/cli.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/harness_bench/drivers.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/harness_bench/offline.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/harness_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/harness_usage.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/html_report.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/improvement_init.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/improvement_verifier.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/__init__.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/crewai.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/harbor/__init__.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/harbor/atif.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/harbor/atif_validation.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/harbor/cli.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/harbor/manifest.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/harbor/trial_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/harbor/trials.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/harbor/verifier.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/hermes.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/hermes_cli.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/hermes_recorder.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/langgraph.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/langgraph_harness.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/langgraph_recovery.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/omnigent/__init__.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/omnigent/cli.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/omnigent/evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/omnigent/telemetry.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/openai.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/openai_agents.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/sdk.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/integrations/vercel_ai.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/__init__.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/artifacts.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/cli.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/cohort_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/cohorts.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/contracts.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/coordination.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/otlp_jsonl.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/otlp_validation.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/registry.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interoperability/validation.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/intervention_service.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/intervention_store.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/interventions.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/issues.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/judgment_adapters.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/judgment_benchmark_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/judgment_benchmarks.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/judgment_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/judgment_views.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/judgments.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/loop_guards.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/loop_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/markdown.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/metrics.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/migrations.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/model_routing.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/onboarding.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/operations.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/optimizer.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/otel.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/otel_ids.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/otel_semantics.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/parallelism.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/patches.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/plan_export.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/policy_promotion.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/promotion_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/promotion_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/quality.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/ranking.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/recovery_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/repetitions.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/replay.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/retention.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/retention_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/reuse_experiments.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/routing_checks.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/routing_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/rules.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/runtime.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/savings.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/scheduling_plan.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/scheduling_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/schema.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/semantic_rules.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/semantic_waste.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/semantic_waste_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/server.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/store.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/structural_experiments.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/structural_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/structured_quality.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/studies.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/study_statistics.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/substitution_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/substitution_export.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/substitution_reports.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/substitution_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/substitutions.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/timing.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/tokens.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/tool_scheduling.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/trace_sources.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/tracer.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/value.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/workflow_types.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop/workflows.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop_profiler.egg-info/dependency_links.txt +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop_profiler.egg-info/entry_points.txt +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop_profiler.egg-info/requires.txt +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop_profiler.egg-info/top_level.txt +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/dashboard/__init__.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/dashboard/app.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/dashboard/streamlit_compat.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/dashboard/trace_upload.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/dashboard/value_view.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/setup.cfg +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_ablations.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_aggregates.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_api_versioning.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_batch_data_pipeline.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_budgets.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_bump_version.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_calibration.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_capability_registry.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_checkpoint_recovery.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_ci_command.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_ci_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_cli_output_paths.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_cli_store_commands.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_cli_trace_inputs.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_client.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_client_transport.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_codex_exec_runner.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_completion.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_context_controls.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_context_reuse_experiments.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_context_study.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_costs.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_crewai_integration.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_cursor_server.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_cursor_shape_validation.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_dashboard_trace_upload.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_dashboard_value_view.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_decorators.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_demo_cli.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_dependabot_config.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_diagnosis_api.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_distribution_metadata.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_docs_site.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_doctor_autoinstrument.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_drift.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_email_workflow.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_empirical_calibration.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_enforcement_conformance.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_estimates.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_evidence_workflow.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_experiments.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_exporters.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_external_cohorts.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_finding_benchmarks.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_finding_identity.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_finding_rules.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_first_use_cli.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_graph.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_guided_validation.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_guided_verifier.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_harbor_atif.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_harbor_trials.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_harness.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_harness_bench.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_harness_error_usage.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_harness_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_hermes_integration.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_hermes_replay_capture.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_hermes_repository_example.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_hermes_runtime_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_html_report.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_improvement_init.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_incident_triage.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_instrumentation_measurement.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_integration_conformance.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_interoperability_contracts.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_interventions.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_issues.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_judgment_adapters.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_judgment_benchmarks.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_judgment_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_judgment_provider_optional.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_judgments.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_langgraph_conformance.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_langgraph_harness.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_langgraph_integration.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_langgraph_recovery.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_loop_guards.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_markdown.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_markdown_exporters.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_marketplace_workflow.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_metrics.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_migrations.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_model_batching.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_model_routing.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_multiagent_coordination.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_non_agent_study.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_omnigent_telemetry.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_onboarding.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_openai_agents_integration.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_openai_integration.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_operations.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_optimizer.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_otel_ids.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_otel_interop.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_otlp_jsonl.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_parallelization_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_patch_plan.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_patch_source_scope.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_payment_review.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_policy_promotion.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_published_readme.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_python_support.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_quality.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_ranking.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_real_agent_study.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_real_calibration_study.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_real_harness_study.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_release_workflows.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_remote_cli_credentials.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_repetitions.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_replay.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_repository_policy_traversal.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_research_example.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_retention.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_retry_recommendations.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_routing_study.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_rule_error_privacy.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_runtime.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_savings_aggregation.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_scheduling_study.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_semantic_findings.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_semantic_waste.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_server.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_standalone_notices.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_store.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_store_contract.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_streaming_inventory.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_streamlit_compat.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_structural_experiments.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_structured_quality.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_structured_quality_evidence.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_studies.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_substitutions.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_telemetry_conformance.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_timing.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_token_provenance.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_tool_scheduling.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_trace_context.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_trace_failure_recording.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_trace_schema.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_usefulness_benchmark.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_value.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_vercel_ai_integration.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_workflow_storage.py +0 -0
- {agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/tests/test_workflows.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentloop-profiler
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Profiler and optimization layer for AI agent execution graphs
|
|
5
5
|
Author: Dipesh Tharu Mahato
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -160,6 +160,12 @@ fictional notes; it is labeled synthetic. Its timings describe this example only
|
|
|
160
160
|
A faster answer that fails the frozen correctness checks is rejected with exit
|
|
161
161
|
code 1. Failed attempts and unknown costs remain in the report.
|
|
162
162
|
|
|
163
|
+
When you already have both versions, `agentloop improve compare` runs the
|
|
164
|
+
baseline, the frozen session, an interleaved before/after capture and the
|
|
165
|
+
verdict in one command. Pass the unchanged runner as repeated `--before-arg`
|
|
166
|
+
values and the changed runner after `--`. See
|
|
167
|
+
[comparing two versions in one command](https://dipeshbabu.github.io/agentloop/GUIDED_OPTIMIZATION/#compare-two-versions-in-one-command).
|
|
168
|
+
|
|
163
169
|
To connect your application, run `agentloop improve init --agent my_agent:answer`
|
|
164
170
|
in its project directory. The generated adapter supports synchronous and async
|
|
165
171
|
Python callables. Replace the example task inputs and expected outputs with
|
|
@@ -102,6 +102,12 @@ fictional notes; it is labeled synthetic. Its timings describe this example only
|
|
|
102
102
|
A faster answer that fails the frozen correctness checks is rejected with exit
|
|
103
103
|
code 1. Failed attempts and unknown costs remain in the report.
|
|
104
104
|
|
|
105
|
+
When you already have both versions, `agentloop improve compare` runs the
|
|
106
|
+
baseline, the frozen session, an interleaved before/after capture and the
|
|
107
|
+
verdict in one command. Pass the unchanged runner as repeated `--before-arg`
|
|
108
|
+
values and the changed runner after `--`. See
|
|
109
|
+
[comparing two versions in one command](https://dipeshbabu.github.io/agentloop/GUIDED_OPTIMIZATION/#compare-two-versions-in-one-command).
|
|
110
|
+
|
|
105
111
|
To connect your application, run `agentloop improve init --agent my_agent:answer`
|
|
106
112
|
in its project directory. The generated adapter supports synchronous and async
|
|
107
113
|
Python callables. Replace the example task inputs and expected outputs with
|
|
@@ -424,6 +424,66 @@ def _runner_budget(value):
|
|
|
424
424
|
) from error
|
|
425
425
|
|
|
426
426
|
|
|
427
|
+
MIN_SIGN_TEST_PAIRS = 5
|
|
428
|
+
NOISY_SPREAD_PCT = 10.0
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
def planning_guidance(workload, manifest, traces, objective, minimum_improvement):
|
|
432
|
+
"""Warn when the planned comparison cannot separate a change from noise.
|
|
433
|
+
|
|
434
|
+
The sign test needs at least five pairs before even a unanimous result can
|
|
435
|
+
fall below p = 0.05. When repeated baseline attempts of the same task vary
|
|
436
|
+
by more than the required improvement, smaller differences may be noise.
|
|
437
|
+
"""
|
|
438
|
+
notes = []
|
|
439
|
+
pairs = len(workload["tasks"]) * workload["repetitions"]
|
|
440
|
+
if pairs < MIN_SIGN_TEST_PAIRS:
|
|
441
|
+
notes.append(
|
|
442
|
+
{
|
|
443
|
+
"kind": "few_pairs",
|
|
444
|
+
"pairs": pairs,
|
|
445
|
+
"message": f"Only {pairs} pair{'s' if pairs != 1 else ''} planned. Even if every "
|
|
446
|
+
"pair improves, a one-sided sign test cannot fall below p = 0.05 with fewer than "
|
|
447
|
+
f"{MIN_SIGN_TEST_PAIRS} pairs. Add tasks or raise repetitions in the task file.",
|
|
448
|
+
}
|
|
449
|
+
)
|
|
450
|
+
if workload["repetitions"] < 2:
|
|
451
|
+
notes.append(
|
|
452
|
+
{
|
|
453
|
+
"kind": "noise_unmeasured",
|
|
454
|
+
"message": "Each task runs once, so baseline run-to-run variation cannot be "
|
|
455
|
+
"measured. Use at least 2 repetitions to see how noisy the agent is.",
|
|
456
|
+
}
|
|
457
|
+
)
|
|
458
|
+
elif objective == "latency":
|
|
459
|
+
completed = _completed(manifest, traces)
|
|
460
|
+
spreads = []
|
|
461
|
+
for task in workload["tasks"]:
|
|
462
|
+
values = [
|
|
463
|
+
trace.elapsed_ms
|
|
464
|
+
for (task_id, _), trace in completed.items()
|
|
465
|
+
if task_id == task["id"] and _trace_usable(trace)
|
|
466
|
+
]
|
|
467
|
+
middle = statistics.median(values) if len(values) >= 2 else 0
|
|
468
|
+
if middle > 0:
|
|
469
|
+
spreads.append((max(values) - min(values)) / middle * 100)
|
|
470
|
+
if spreads:
|
|
471
|
+
spread = statistics.median(spreads)
|
|
472
|
+
if spread >= NOISY_SPREAD_PCT and spread > minimum_improvement:
|
|
473
|
+
notes.append(
|
|
474
|
+
{
|
|
475
|
+
"kind": "noisy_baseline",
|
|
476
|
+
"spread_pct": round(spread, 2),
|
|
477
|
+
"message": f"Baseline latency of the same task varied by a median "
|
|
478
|
+
f"{spread:.1f}% between repetitions, more than the "
|
|
479
|
+
f"{minimum_improvement:g}% required improvement. Smaller differences "
|
|
480
|
+
"may be noise: require a larger improvement, add repetitions, or "
|
|
481
|
+
"compare against an interleaved control with the aggregate decision.",
|
|
482
|
+
}
|
|
483
|
+
)
|
|
484
|
+
return notes
|
|
485
|
+
|
|
486
|
+
|
|
427
487
|
def start(
|
|
428
488
|
workload_path,
|
|
429
489
|
baseline_path,
|
|
@@ -515,6 +575,9 @@ def start(
|
|
|
515
575
|
"gates": asdict(gates),
|
|
516
576
|
"cases": cases,
|
|
517
577
|
"baseline_capture": manifest,
|
|
578
|
+
"planning_notes": planning_guidance(
|
|
579
|
+
workload, manifest, traces, objective, minimum_improvement
|
|
580
|
+
),
|
|
518
581
|
}
|
|
519
582
|
if verifier is not None:
|
|
520
583
|
specification["verifier"] = verifier.declaration()
|
|
@@ -1060,3 +1123,113 @@ def finish(session_path, candidate_path, root, *, change, verifier=None):
|
|
|
1060
1123
|
|
|
1061
1124
|
export_report(root, report)
|
|
1062
1125
|
return report
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
COMPARE_LAYOUT = {
|
|
1129
|
+
"baseline": "baseline",
|
|
1130
|
+
"session": "session",
|
|
1131
|
+
"paired": "paired",
|
|
1132
|
+
"results": "results",
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
def compare(
|
|
1137
|
+
workload_path,
|
|
1138
|
+
root,
|
|
1139
|
+
before,
|
|
1140
|
+
after,
|
|
1141
|
+
*,
|
|
1142
|
+
change,
|
|
1143
|
+
timeout=180,
|
|
1144
|
+
show_output=False,
|
|
1145
|
+
focus=None,
|
|
1146
|
+
objective="latency",
|
|
1147
|
+
minimum_improvement=0,
|
|
1148
|
+
decision="aggregate",
|
|
1149
|
+
verifier=None,
|
|
1150
|
+
verifier_timeout=DEFAULT_TIMEOUT,
|
|
1151
|
+
max_runner_regression_ms=None,
|
|
1152
|
+
progress=None,
|
|
1153
|
+
):
|
|
1154
|
+
"""Run the whole guided comparison for an unchanged and a changed runner.
|
|
1155
|
+
|
|
1156
|
+
The ``before`` runner is captured as the baseline, the session is frozen,
|
|
1157
|
+
and the ``after`` runner is then captured with ``before`` as an
|
|
1158
|
+
interleaved control. ``before`` must therefore stay runnable and unchanged,
|
|
1159
|
+
for example from a separate git worktree. Every stage writes its usual
|
|
1160
|
+
artifacts under ``root`` (see ``COMPARE_LAYOUT``), so a failed run can be
|
|
1161
|
+
inspected or resumed with the individual commands.
|
|
1162
|
+
"""
|
|
1163
|
+
notify = progress or (lambda message: None)
|
|
1164
|
+
# Check cheap inputs before any runner executes, so a typo cannot waste a
|
|
1165
|
+
# full baseline capture.
|
|
1166
|
+
require(isinstance(change, str) and bool(change.strip()), "Describe the change being compared")
|
|
1167
|
+
for argv, side in ((before, "before"), (after, "after")):
|
|
1168
|
+
require(
|
|
1169
|
+
isinstance(argv, (list, tuple))
|
|
1170
|
+
and argv
|
|
1171
|
+
and all(isinstance(a, str) and a for a in argv),
|
|
1172
|
+
f"Supply an explicit {side} runner command",
|
|
1173
|
+
)
|
|
1174
|
+
require(list(before) != list(after), "The before and after runners must differ")
|
|
1175
|
+
require(objective in {"latency", "cost"}, "Objective must be latency or cost")
|
|
1176
|
+
decision = decision.replace("-", "_") if isinstance(decision, str) else decision
|
|
1177
|
+
require(decision in DECISIONS, "Decision must be per-pair or aggregate")
|
|
1178
|
+
_runner_budget(max_runner_regression_ms)
|
|
1179
|
+
require(
|
|
1180
|
+
type(minimum_improvement) in (int, float)
|
|
1181
|
+
and math.isfinite(minimum_improvement)
|
|
1182
|
+
and minimum_improvement >= 0,
|
|
1183
|
+
"Minimum improvement must be finite and nonnegative",
|
|
1184
|
+
)
|
|
1185
|
+
if verifier is not None:
|
|
1186
|
+
LocalVerifier.read(verifier, verifier_timeout)
|
|
1187
|
+
read_workload(workload_path)
|
|
1188
|
+
root = Path(root).resolve()
|
|
1189
|
+
root.mkdir(parents=True, exist_ok=False)
|
|
1190
|
+
paths = {name: local_path(root, relative) for name, relative in COMPARE_LAYOUT.items()}
|
|
1191
|
+
|
|
1192
|
+
notify("Capturing the baseline with the before runner")
|
|
1193
|
+
baseline = capture(
|
|
1194
|
+
workload_path, paths["baseline"], list(before), timeout=timeout, show_output=show_output
|
|
1195
|
+
)
|
|
1196
|
+
completed = sum(row["status"] == "completed" for row in baseline["runs"])
|
|
1197
|
+
require(
|
|
1198
|
+
completed > 0,
|
|
1199
|
+
"No baseline attempt completed. Fix the before runner, using "
|
|
1200
|
+
f"{paths['baseline'] / 'capture.json'} and --show-runner-output, then rerun.",
|
|
1201
|
+
)
|
|
1202
|
+
notify(
|
|
1203
|
+
f"Baseline captured {completed} of {len(baseline['runs'])} attempts; freezing the session"
|
|
1204
|
+
)
|
|
1205
|
+
specification = start(
|
|
1206
|
+
workload_path,
|
|
1207
|
+
paths["baseline"] / "capture.json",
|
|
1208
|
+
paths["session"],
|
|
1209
|
+
focus=focus,
|
|
1210
|
+
objective=objective,
|
|
1211
|
+
minimum_improvement=minimum_improvement,
|
|
1212
|
+
decision=decision,
|
|
1213
|
+
verifier=verifier,
|
|
1214
|
+
verifier_timeout=verifier_timeout,
|
|
1215
|
+
max_runner_regression_ms=max_runner_regression_ms,
|
|
1216
|
+
)
|
|
1217
|
+
for note in specification["planning_notes"]:
|
|
1218
|
+
notify(f"Note: {note['message']}")
|
|
1219
|
+
notify("Capturing the after runner, alternating with the before runner as a control")
|
|
1220
|
+
capture(
|
|
1221
|
+
workload_path,
|
|
1222
|
+
paths["paired"],
|
|
1223
|
+
list(after),
|
|
1224
|
+
timeout=timeout,
|
|
1225
|
+
show_output=show_output,
|
|
1226
|
+
control=list(before),
|
|
1227
|
+
)
|
|
1228
|
+
notify("Comparing every planned pair")
|
|
1229
|
+
return finish(
|
|
1230
|
+
paths["session"] / "session.json",
|
|
1231
|
+
paths["paired"] / "capture.json",
|
|
1232
|
+
paths["results"],
|
|
1233
|
+
change=change,
|
|
1234
|
+
verifier=verifier,
|
|
1235
|
+
)
|
|
@@ -145,6 +145,7 @@ def start_command(
|
|
|
145
145
|
console.print(
|
|
146
146
|
f"Investigation focus is {specification['focus'] or 'unavailable'}.", markup=False
|
|
147
147
|
)
|
|
148
|
+
_print_planning_notes(specification)
|
|
148
149
|
console.print(
|
|
149
150
|
f"Review {out / 'plan.md'}, apply your change, then capture the same tasks again.",
|
|
150
151
|
markup=False,
|
|
@@ -173,6 +174,16 @@ def finish_command(
|
|
|
173
174
|
report = improvement.finish(session, candidate, out, change=change, verifier=verifier)
|
|
174
175
|
except (OSError, ValueError, TypeError, KeyError) as exc:
|
|
175
176
|
raise typer.BadParameter(str(exc)) from exc
|
|
177
|
+
_print_report(report, out)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def _print_planning_notes(specification):
|
|
181
|
+
for note in specification.get("planning_notes", []):
|
|
182
|
+
console.print(f"Note: {note['message']}", markup=False)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def _print_report(report, out):
|
|
186
|
+
"""Print the verdict and timing summary; exit 1 when the change is rejected."""
|
|
176
187
|
verdict = report["decision"]
|
|
177
188
|
if verdict["mode"] == "aggregate":
|
|
178
189
|
console.print(_headline(report), markup=False)
|
|
@@ -213,3 +224,70 @@ def finish_command(
|
|
|
213
224
|
)
|
|
214
225
|
if not report["passed"]:
|
|
215
226
|
raise typer.Exit(1)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@improve_app.command("compare")
|
|
230
|
+
def compare_command(
|
|
231
|
+
tasks: Path | None = typer.Option(None, help="Fixed tasks, overriding the project config."),
|
|
232
|
+
project: Path = typer.Option(
|
|
233
|
+
Path("agentloop.toml"), help="Data-only project config used when --tasks is omitted."
|
|
234
|
+
),
|
|
235
|
+
out: Path = typer.Option(..., help="Fresh directory for every stage of the comparison."),
|
|
236
|
+
before_arg: list[str] = typer.Option(
|
|
237
|
+
...,
|
|
238
|
+
"--before-arg",
|
|
239
|
+
help="One argument of the unchanged before runner; repeat for each argument. "
|
|
240
|
+
"It runs the baseline and then alternates with the after runner as a control.",
|
|
241
|
+
),
|
|
242
|
+
change: str = typer.Option(..., help="Describe the change the after runner applies."),
|
|
243
|
+
timeout: float = typer.Option(180, min=0.01, max=3600, help="Seconds per task attempt."),
|
|
244
|
+
show_runner_output: bool = typer.Option(
|
|
245
|
+
False, help="Stream the runners' stdout and stderr for diagnosis."
|
|
246
|
+
),
|
|
247
|
+
focus: str | None = typer.Option(
|
|
248
|
+
None, help="Finding type to investigate. Defaults to the first baseline finding."
|
|
249
|
+
),
|
|
250
|
+
objective: str = typer.Option("latency", help="latency or cost."),
|
|
251
|
+
minimum_improvement: float = typer.Option(
|
|
252
|
+
0, min=0, help="Required percentage gain in the selected objective."
|
|
253
|
+
),
|
|
254
|
+
max_runner_regression_ms: float | None = typer.Option(
|
|
255
|
+
None, min=0, help="Optional maximum runner wall-time increase in ms for each pair."
|
|
256
|
+
),
|
|
257
|
+
decision: str = typer.Option(
|
|
258
|
+
"aggregate",
|
|
259
|
+
help="aggregate (default here) judges the median paired improvement; per-pair "
|
|
260
|
+
"requires every pair to improve. Correctness is checked per pair in both.",
|
|
261
|
+
),
|
|
262
|
+
verifier: Path | None = typer.Option(None, help="Explicit trusted local Python verifier file."),
|
|
263
|
+
verifier_timeout: float = typer.Option(
|
|
264
|
+
DEFAULT_TIMEOUT, min=0.01, max=3600, help="Seconds per verifier execution."
|
|
265
|
+
),
|
|
266
|
+
command: list[str] = typer.Argument(
|
|
267
|
+
..., help="Explicit after-runner argv after --. Receives a JSON request on stdin."
|
|
268
|
+
),
|
|
269
|
+
):
|
|
270
|
+
"""Capture, freeze, interleave and compare an unchanged and a changed runner."""
|
|
271
|
+
try:
|
|
272
|
+
report = improvement.compare(
|
|
273
|
+
tasks_path(tasks, project),
|
|
274
|
+
out,
|
|
275
|
+
before_arg,
|
|
276
|
+
command,
|
|
277
|
+
change=change,
|
|
278
|
+
timeout=timeout,
|
|
279
|
+
show_output=show_runner_output,
|
|
280
|
+
focus=focus,
|
|
281
|
+
objective=objective,
|
|
282
|
+
minimum_improvement=minimum_improvement,
|
|
283
|
+
decision=decision,
|
|
284
|
+
verifier=verifier,
|
|
285
|
+
verifier_timeout=verifier_timeout,
|
|
286
|
+
max_runner_regression_ms=max_runner_regression_ms,
|
|
287
|
+
progress=lambda message: console.print(message, markup=False),
|
|
288
|
+
)
|
|
289
|
+
except (OSError, ValueError, TypeError, KeyError) as exc:
|
|
290
|
+
raise typer.BadParameter(str(exc)) from exc
|
|
291
|
+
session = out / improvement.COMPARE_LAYOUT["session"]
|
|
292
|
+
console.print(f"Baseline findings and plan: {session / 'plan.md'}", markup=False)
|
|
293
|
+
_print_report(report, out / improvement.COMPARE_LAYOUT["results"])
|
|
@@ -45,6 +45,10 @@ def plan_markdown(specification):
|
|
|
45
45
|
]
|
|
46
46
|
if specification.get("verifier"):
|
|
47
47
|
lines.extend([_verifier_scope(specification["verifier"]), ""])
|
|
48
|
+
if notes := specification.get("planning_notes"):
|
|
49
|
+
lines.extend(["## Evidence strength", ""])
|
|
50
|
+
lines.extend(f"- {markdown_text(note['message'])}" for note in notes)
|
|
51
|
+
lines.append("")
|
|
48
52
|
if (limit := specification.get("max_runner_regression_ms")) is not None:
|
|
49
53
|
lines.extend(
|
|
50
54
|
[f"Runner wall-time gate allows an increase of up to {limit:g} ms in each pair.", ""]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentloop-profiler
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Profiler and optimization layer for AI agent execution graphs
|
|
5
5
|
Author: Dipesh Tharu Mahato
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -160,6 +160,12 @@ fictional notes; it is labeled synthetic. Its timings describe this example only
|
|
|
160
160
|
A faster answer that fails the frozen correctness checks is rejected with exit
|
|
161
161
|
code 1. Failed attempts and unknown costs remain in the report.
|
|
162
162
|
|
|
163
|
+
When you already have both versions, `agentloop improve compare` runs the
|
|
164
|
+
baseline, the frozen session, an interleaved before/after capture and the
|
|
165
|
+
verdict in one command. Pass the unchanged runner as repeated `--before-arg`
|
|
166
|
+
values and the changed runner after `--`. See
|
|
167
|
+
[comparing two versions in one command](https://dipeshbabu.github.io/agentloop/GUIDED_OPTIMIZATION/#compare-two-versions-in-one-command).
|
|
168
|
+
|
|
163
169
|
To connect your application, run `agentloop improve init --agent my_agent:answer`
|
|
164
170
|
in its project directory. The generated adapter supports synchronous and async
|
|
165
171
|
Python callables. Replace the example task inputs and expected outputs with
|
{agentloop_profiler-0.2.4 → agentloop_profiler-0.2.5}/agentloop_profiler.egg-info/SOURCES.txt
RENAMED
|
@@ -188,6 +188,7 @@ tests/test_capability_registry.py
|
|
|
188
188
|
tests/test_checkpoint_recovery.py
|
|
189
189
|
tests/test_ci_command.py
|
|
190
190
|
tests/test_ci_evidence.py
|
|
191
|
+
tests/test_claude_code_runner.py
|
|
191
192
|
tests/test_cli_output_paths.py
|
|
192
193
|
tests/test_cli_store_commands.py
|
|
193
194
|
tests/test_cli_trace_inputs.py
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import stat
|
|
6
|
+
import subprocess
|
|
7
|
+
import sys
|
|
8
|
+
from datetime import datetime, timezone
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from agentloop.events import AgentEvent
|
|
13
|
+
from agentloop.findings import build_diagnosis
|
|
14
|
+
from agentloop.tracer import AgentTrace
|
|
15
|
+
from examples.claude_code_runner import convert, task_prompt
|
|
16
|
+
|
|
17
|
+
USAGE = {
|
|
18
|
+
"input_tokens": 12,
|
|
19
|
+
"cache_creation_input_tokens": 3000,
|
|
20
|
+
"cache_read_input_tokens": 15000,
|
|
21
|
+
"output_tokens": 80,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def assistant(message_id, *content, usage=USAGE):
|
|
26
|
+
return {
|
|
27
|
+
"type": "assistant",
|
|
28
|
+
"message": {
|
|
29
|
+
"id": message_id,
|
|
30
|
+
"model": "claude-test",
|
|
31
|
+
"content": list(content),
|
|
32
|
+
"usage": usage,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def tool_use(tool_id, name, value):
|
|
38
|
+
return {"type": "tool_use", "id": tool_id, "name": name, "input": value}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def tool_result(tool_id, text, is_error=False):
|
|
42
|
+
return {
|
|
43
|
+
"type": "user",
|
|
44
|
+
"message": {
|
|
45
|
+
"role": "user",
|
|
46
|
+
"content": [
|
|
47
|
+
{
|
|
48
|
+
"type": "tool_result",
|
|
49
|
+
"tool_use_id": tool_id,
|
|
50
|
+
"content": text,
|
|
51
|
+
"is_error": is_error,
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
INIT = {"type": "system", "subtype": "init", "session_id": "s1", "model": "claude-test"}
|
|
59
|
+
RESULT = {
|
|
60
|
+
"type": "result",
|
|
61
|
+
"subtype": "success",
|
|
62
|
+
"is_error": False,
|
|
63
|
+
"result": ">=3.11",
|
|
64
|
+
"num_turns": 2,
|
|
65
|
+
"duration_ms": 3000,
|
|
66
|
+
"duration_api_ms": 2500,
|
|
67
|
+
"total_cost_usd": 0.0123,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# Shape of `claude -p --output-format stream-json --verbose`, shortened. Claude
|
|
71
|
+
# Code may emit one assistant event per content block of the same response.
|
|
72
|
+
STREAM = [
|
|
73
|
+
(0.5, INIT),
|
|
74
|
+
(1.5, assistant("msg_1", {"type": "text", "text": "Checking."})),
|
|
75
|
+
(2.0, assistant("msg_1", tool_use("toolu_1", "Read", {"file_path": "pyproject.toml"}))),
|
|
76
|
+
(2.3, tool_result("toolu_1", 'requires-python = ">=3.11"')),
|
|
77
|
+
(3.0, assistant("msg_2", {"type": "text", "text": ">=3.11"})),
|
|
78
|
+
(3.1, RESULT),
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def run_convert(stream):
|
|
83
|
+
return convert(
|
|
84
|
+
[(moment, json.dumps(event) + "\n") for moment, event in stream],
|
|
85
|
+
run_id="run_test",
|
|
86
|
+
root_id="evt_root",
|
|
87
|
+
origin=datetime(2026, 11, 19, tzinfo=timezone.utc),
|
|
88
|
+
clock=0.0,
|
|
89
|
+
model=None,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_each_response_is_one_model_span_and_each_tool_use_a_tool_span():
|
|
94
|
+
events, output, usage_seen, failure, details = run_convert(STREAM)
|
|
95
|
+
assert (output, usage_seen, failure) == (">=3.11", True, None)
|
|
96
|
+
assert [(event.event_type, event.name) for event in events] == [
|
|
97
|
+
("model_call", "claude_response"),
|
|
98
|
+
("tool_call", "Read"),
|
|
99
|
+
("model_call", "claude_response"),
|
|
100
|
+
]
|
|
101
|
+
decision, tool, answer = events
|
|
102
|
+
assert decision.duration_ms == pytest.approx(1500)
|
|
103
|
+
assert decision.metadata["content_types"] == ["text", "tool_use"]
|
|
104
|
+
assert tool.duration_ms == pytest.approx(300)
|
|
105
|
+
assert json.loads(tool.input_text) == {"file_path": "pyproject.toml"}
|
|
106
|
+
assert tool.output_text == 'requires-python = ">=3.11"'
|
|
107
|
+
assert answer.duration_ms == pytest.approx(700)
|
|
108
|
+
assert answer.output_text == ">=3.11"
|
|
109
|
+
assert details["claude_total_cost_usd"] == 0.0123
|
|
110
|
+
assert details["claude_num_turns"] == 2
|
|
111
|
+
assert details["claude_session_id"] == "s1"
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def test_usage_is_set_once_per_response_and_includes_cache_tokens():
|
|
115
|
+
events, *_ = run_convert(STREAM)
|
|
116
|
+
decision = events[0]
|
|
117
|
+
assert decision.input_tokens == 12 + 3000 + 15000
|
|
118
|
+
assert decision.output_tokens == 80
|
|
119
|
+
assert decision.token_provenance == "provider"
|
|
120
|
+
assert decision.model == "claude-test"
|
|
121
|
+
assert decision.metadata["usage_scope"] == "request"
|
|
122
|
+
assert decision.metadata["cached_input_tokens"] == 15000
|
|
123
|
+
assert decision.metadata["cache_creation_input_tokens"] == 3000
|
|
124
|
+
assert "start" not in decision.metadata
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def test_parallel_tool_uses_share_one_model_span():
|
|
128
|
+
stream = [
|
|
129
|
+
STREAM[0],
|
|
130
|
+
(
|
|
131
|
+
1.0,
|
|
132
|
+
assistant(
|
|
133
|
+
"msg_1",
|
|
134
|
+
tool_use("a", "Grep", {"pattern": "x"}),
|
|
135
|
+
tool_use("b", "Glob", {"pattern": "*.py"}),
|
|
136
|
+
),
|
|
137
|
+
),
|
|
138
|
+
(1.4, tool_result("a", "hit")),
|
|
139
|
+
(1.6, tool_result("b", [{"type": "text", "text": "a.py"}])),
|
|
140
|
+
(2.6, assistant("msg_2", {"type": "text", "text": "done"})),
|
|
141
|
+
]
|
|
142
|
+
events, *_ = run_convert(stream)
|
|
143
|
+
assert [event.event_type for event in events] == [
|
|
144
|
+
"model_call",
|
|
145
|
+
"tool_call",
|
|
146
|
+
"tool_call",
|
|
147
|
+
"model_call",
|
|
148
|
+
]
|
|
149
|
+
assert events[2].output_text == "a.py"
|
|
150
|
+
assert events[3].duration_ms == pytest.approx(1000)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def test_tool_errors_and_failed_results_are_retained():
|
|
154
|
+
stream = [
|
|
155
|
+
STREAM[0],
|
|
156
|
+
(1.0, assistant("msg_1", tool_use("t", "Bash", {"command": "rm -rf x"}))),
|
|
157
|
+
(1.1, tool_result("t", "Permission to use Bash has been denied.", is_error=True)),
|
|
158
|
+
(
|
|
159
|
+
2.0,
|
|
160
|
+
{
|
|
161
|
+
"type": "result",
|
|
162
|
+
"subtype": "error_max_turns",
|
|
163
|
+
"is_error": True,
|
|
164
|
+
"num_turns": 1,
|
|
165
|
+
},
|
|
166
|
+
),
|
|
167
|
+
]
|
|
168
|
+
events, output, _, failure, _ = run_convert(stream)
|
|
169
|
+
tool = next(event for event in events if event.event_type == "tool_call")
|
|
170
|
+
assert tool.status == "error" and "denied" in tool.error
|
|
171
|
+
assert output is None
|
|
172
|
+
assert failure == "error_max_turns"
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def test_converted_events_form_an_analyzable_trace():
|
|
176
|
+
events, output, *_ = run_convert(STREAM)
|
|
177
|
+
trace = AgentTrace("claude test", metadata={"output": output})
|
|
178
|
+
trace.add_event(
|
|
179
|
+
AgentEvent(
|
|
180
|
+
event_id="evt_root",
|
|
181
|
+
run_id=trace.run_id,
|
|
182
|
+
event_type="agent_step",
|
|
183
|
+
name="claude_code",
|
|
184
|
+
started_at=events[0].started_at,
|
|
185
|
+
ended_at=events[-1].ended_at,
|
|
186
|
+
duration_ms=3100,
|
|
187
|
+
metadata={"operation_kind": "agent"},
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
for event in events:
|
|
191
|
+
event.run_id = trace.run_id
|
|
192
|
+
trace.add_event(event)
|
|
193
|
+
trace.finish()
|
|
194
|
+
restored = AgentTrace.from_dict(json.loads(json.dumps(trace.to_dict())))
|
|
195
|
+
assert build_diagnosis(restored)["run_id"] == trace.run_id
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@pytest.mark.parametrize(
|
|
199
|
+
("value", "instructions", "expected"),
|
|
200
|
+
[
|
|
201
|
+
("plain", "", "plain"),
|
|
202
|
+
({"prompt": "object"}, "", "object"),
|
|
203
|
+
({"question": "legacy"}, "Be brief.", "Be brief.\n\nlegacy"),
|
|
204
|
+
],
|
|
205
|
+
)
|
|
206
|
+
def test_task_prompt_accepts_strings_and_prompt_objects(value, instructions, expected):
|
|
207
|
+
assert task_prompt(value, instructions) == expected
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
FAKE_CLAUDE = """import json, os, sys
|
|
211
|
+
prompt = sys.stdin.read()
|
|
212
|
+
record = {"argv": sys.argv[1:], "cwd": os.getcwd(), "prompt": prompt}
|
|
213
|
+
with open(os.environ["FAKE_CLAUDE_RECORD"], "w", encoding="utf-8") as handle:
|
|
214
|
+
json.dump(record, handle)
|
|
215
|
+
for event in EVENTS:
|
|
216
|
+
print(json.dumps(event), flush=True)
|
|
217
|
+
"""
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def test_runner_drives_the_cli_and_writes_a_successful_trace(tmp_path):
|
|
221
|
+
script = tmp_path / "fake_claude.py"
|
|
222
|
+
events = [event for _, event in STREAM]
|
|
223
|
+
script.write_text(f"EVENTS = {events!r}\n" + FAKE_CLAUDE, encoding="utf-8")
|
|
224
|
+
if os.name == "nt":
|
|
225
|
+
executable = tmp_path / "fake-claude.cmd"
|
|
226
|
+
executable.write_text(f'@"{sys.executable}" "{script}" %*\n', encoding="utf-8")
|
|
227
|
+
else:
|
|
228
|
+
executable = tmp_path / "fake-claude"
|
|
229
|
+
executable.write_text(
|
|
230
|
+
f"#!{sys.executable}\n" + script.read_text(encoding="utf-8"), encoding="utf-8"
|
|
231
|
+
)
|
|
232
|
+
executable.chmod(executable.stat().st_mode | stat.S_IXUSR)
|
|
233
|
+
workdir = tmp_path / "repo"
|
|
234
|
+
workdir.mkdir()
|
|
235
|
+
record = tmp_path / "record.json"
|
|
236
|
+
trace_path = tmp_path / "trace.json"
|
|
237
|
+
request = {
|
|
238
|
+
"task_id": "python",
|
|
239
|
+
"repetition": 0,
|
|
240
|
+
"input": {"prompt": "Which Python?"},
|
|
241
|
+
"trace_path": str(trace_path),
|
|
242
|
+
}
|
|
243
|
+
completed = subprocess.run( # noqa: S603
|
|
244
|
+
[
|
|
245
|
+
sys.executable,
|
|
246
|
+
"examples/claude_code_runner.py",
|
|
247
|
+
"--claude",
|
|
248
|
+
str(executable),
|
|
249
|
+
"--cd",
|
|
250
|
+
str(workdir),
|
|
251
|
+
"--model",
|
|
252
|
+
"claude-test",
|
|
253
|
+
"--condition",
|
|
254
|
+
"baseline",
|
|
255
|
+
"--",
|
|
256
|
+
"--max-turns",
|
|
257
|
+
"4",
|
|
258
|
+
],
|
|
259
|
+
input=json.dumps(request) + "\n",
|
|
260
|
+
capture_output=True,
|
|
261
|
+
text=True,
|
|
262
|
+
env={**os.environ, "FAKE_CLAUDE_RECORD": str(record)},
|
|
263
|
+
timeout=60,
|
|
264
|
+
check=False,
|
|
265
|
+
)
|
|
266
|
+
assert completed.returncode == 0, completed.stderr
|
|
267
|
+
seen = json.loads(record.read_text(encoding="utf-8"))
|
|
268
|
+
assert seen["argv"] == [
|
|
269
|
+
"-p",
|
|
270
|
+
"--output-format",
|
|
271
|
+
"stream-json",
|
|
272
|
+
"--verbose",
|
|
273
|
+
"--allowedTools",
|
|
274
|
+
"Read,Grep,Glob",
|
|
275
|
+
"--model",
|
|
276
|
+
"claude-test",
|
|
277
|
+
"--max-turns",
|
|
278
|
+
"4",
|
|
279
|
+
]
|
|
280
|
+
assert os.path.samefile(seen["cwd"], workdir)
|
|
281
|
+
assert seen["prompt"] == "Which Python?"
|
|
282
|
+
trace = AgentTrace.from_dict(json.loads(trace_path.read_text(encoding="utf-8")))
|
|
283
|
+
assert trace.metadata["output"] == ">=3.11"
|
|
284
|
+
assert trace.metadata["success"] is True
|
|
285
|
+
assert trace.metadata["integration"] == "claude_code"
|
|
286
|
+
kinds = [event.event_type for event in trace.events]
|
|
287
|
+
assert kinds.count("model_call") == 2 and kinds.count("tool_call") == 1
|