agent-apprenticeship 0.1.5 → 0.1.7
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.
- package/README.md +0 -197
- package/bin/agent-apprenticeship.js +85 -37
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/src/agent_apprenticeship_trace/__init__.py +1 -1
- package/src/agent_apprenticeship_trace/actual_outputs_normalizer.py +104 -28
- package/src/agent_apprenticeship_trace/apprentice_adapters.py +3 -1
- package/src/agent_apprenticeship_trace/artifact_resolver.py +6 -0
- package/src/agent_apprenticeship_trace/bundle_exporter.py +132 -2
- package/src/agent_apprenticeship_trace/cli.py +1229 -269
- package/src/agent_apprenticeship_trace/codex_runner.py +89 -6
- package/src/agent_apprenticeship_trace/config.py +251 -32
- package/src/agent_apprenticeship_trace/ecosystem_r2.py +515 -0
- package/src/agent_apprenticeship_trace/env.py +5 -5
- package/src/agent_apprenticeship_trace/evaluator.py +127 -11
- package/src/agent_apprenticeship_trace/grader.py +12 -11
- package/src/agent_apprenticeship_trace/learning.py +270 -1
- package/src/agent_apprenticeship_trace/llm_output_normalizer.py +8 -7
- package/src/agent_apprenticeship_trace/loop.py +103 -4
- package/src/agent_apprenticeship_trace/loop_review.py +686 -0
- package/src/agent_apprenticeship_trace/mentor_checkpoints.py +49 -21
- package/src/agent_apprenticeship_trace/openai_structured.py +84 -14
- package/src/agent_apprenticeship_trace/package_exporter.py +1 -1
- package/src/agent_apprenticeship_trace/progress.py +2 -1
- package/src/agent_apprenticeship_trace/public_run.py +369 -57
- package/src/agent_apprenticeship_trace/public_sanitizer.py +40 -3
- package/src/agent_apprenticeship_trace/rubric_generation.py +11 -10
- package/src/agent_apprenticeship_trace/schemas.py +378 -3
- package/src/agent_apprenticeship_trace/task_intake.py +43 -9
- package/src/agent_apprenticeship_trace/tdo.py +2304 -0
- package/src/agent_apprenticeship_trace/trace_normalizer.py +351 -17
- package/src/agent_apprenticeship_trace/trace_prompt.py +38 -11
- package/src/agent_apprenticeship_trace/training_signals.py +1 -1
- package/src/agent_apprenticeship_trace/verifier.py +12 -6
|
@@ -21,19 +21,25 @@ def _model_verifier_active(settings) -> bool:
|
|
|
21
21
|
def deterministic_verify(grader: GraderResult, outputs: ActualOutputs) -> VerifierResult:
|
|
22
22
|
artifact_ok=bool(grader.evidence_refs) and not grader.metadata_json.get('missing_artifacts') and outputs.status == 'success'
|
|
23
23
|
score_ok=0 <= grader.score <= grader.max_score
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
issues=[]
|
|
25
|
+
if not artifact_ok:
|
|
26
|
+
issues.append('missing deliverable evidence')
|
|
27
|
+
if not score_ok:
|
|
28
|
+
issues.append('score inconsistency')
|
|
29
|
+
if grader.hidden_reference_leaked:
|
|
30
|
+
issues.append('hidden reference leakage')
|
|
31
|
+
return VerifierResult(verifier_result_id=f'verifier_{outputs.attempt_id}', task_id=outputs.task_id, attempt_id=outputs.attempt_id, attempt_kind=outputs.attempt_kind, grader_result_id=grader.grader_result_id, verification_status='not_run', artifact_contract_ok=artifact_ok, evidence_grounding_ok=bool(grader.evidence_refs), score_consistency_ok=score_ok, hidden_reference_leaked=grader.hidden_reference_leaked, issues=issues, confidence=0.6, verifier_notes='Structural guardrail checked artifact refs, score bounds, and leakage flags only; Mentor verification did not run.', semantic_evidence_grounding_ok=None, unsupported_claims=[], leakage_check_ok=not grader.hidden_reference_leaked, model=None, provider=None, metadata_json={'score_source': grader.score_source, 'structural_guardrail': True, 'role_status': 'mentor_verifier_unavailable'})
|
|
26
32
|
|
|
27
33
|
def _verifier_prompt(grader: GraderResult, outputs: ActualOutputs, trace: AgentTrace | None, artifact_preview_bundle: dict | None=None) -> str:
|
|
28
34
|
return """Return only valid JSON matching VerifierResult. Do not include markdown.
|
|
29
|
-
Check whether the grader evidence is grounded in actual_outputs
|
|
35
|
+
Check whether the grader evidence is grounded in actual_outputs.json, artifact refs, trace evidence, and especially the artifact content previews. Check score consistency, unsupported claims, and hidden-reference leakage. Do not treat Apprentice Agent self-assessment or self evaluation as outcome evidence. Do not use deterministic fallback judgement; structural guardrails are package-integrity checks only and are not verifier judgments. Return exactly the VerifierResult schema fields. Do not add top-level fields not in schema. If you want to report extra checks such as reproducible, within_time_limit, uses_only_allowed_apis, passed_checks, or within_memory_limit, put them inside metadata_json.extra_model_fields.
|
|
30
36
|
GraderResult JSON:
|
|
31
37
|
""" + json.dumps(grader.model_dump(), sort_keys=True) + "\nActualOutputs JSON:\n" + json.dumps(outputs.model_dump(), sort_keys=True) + "\nArtifact content previews JSON:\n" + json.dumps(artifact_preview_bundle or {}, sort_keys=True)[:16000] + "\nTrace summary JSON:\n" + json.dumps((trace.model_dump() if trace else {}), sort_keys=True)[:12000]
|
|
32
38
|
|
|
33
39
|
def verify_attempt(grader: GraderResult, outputs: ActualOutputs, trace: AgentTrace | None=None, role_root: Path | None=None, package_root: Path | None=None) -> VerifierResult:
|
|
34
40
|
settings=get_settings(); pre=deterministic_verify(grader, outputs); role_root=role_root or Path('outputs/roles')
|
|
35
41
|
artifact_preview_bundle=build_artifact_previews(package_root, grader.evidence_refs or outputs.deliverable_refs or outputs.artifact_refs or outputs.files_created)
|
|
36
|
-
if _model_verifier_active(settings) and
|
|
42
|
+
if _model_verifier_active(settings) and settings.llm_verifier_enabled:
|
|
37
43
|
prompt=_verifier_prompt(grader, outputs, trace, artifact_preview_bundle)
|
|
38
44
|
try:
|
|
39
45
|
provider=_mentor_provider_id()
|
|
@@ -43,7 +49,7 @@ def verify_attempt(grader: GraderResult, outputs: ActualOutputs, trace: AgentTra
|
|
|
43
49
|
parsed=read_json(role_root/'verifier_agent'/outputs.attempt_kind/'parsed_output.json')
|
|
44
50
|
v=VerifierResult.model_validate(parsed)
|
|
45
51
|
v.provider=rr.provider; v.model=rr.model; v.semantic_evidence_grounding_ok=v.semantic_evidence_grounding_ok if v.semantic_evidence_grounding_ok is not None else v.evidence_grounding_ok; v.leakage_check_ok=v.leakage_check_ok if v.leakage_check_ok is not None else not v.hidden_reference_leaked
|
|
46
|
-
v.metadata_json.update({'llm_prompt_ref_internal':str(role_root/'verifier_agent'/outputs.attempt_kind/'prompt.md'),'llm_response_ref_internal':str(role_root/'verifier_agent'/outputs.attempt_kind/'raw_output.txt'),'prompt_hash':sha256_text(prompt),'public_response_summary':'Model verifier checked grounding and score consistency.', **artifact_preview_bundle})
|
|
52
|
+
v.metadata_json.update({'llm_prompt_ref_internal':str(role_root/'verifier_agent'/outputs.attempt_kind/'prompt.md'),'llm_response_ref_internal':str(role_root/'verifier_agent'/outputs.attempt_kind/'raw_output.txt'),'prompt_hash':sha256_text(prompt),'public_response_summary':'Mentor Model verifier checked grounding and score consistency.', **artifact_preview_bundle})
|
|
47
53
|
return v
|
|
48
54
|
if settings.evaluation_mode == 'llm_required' or settings.llm_fail_closed:
|
|
49
55
|
raise RuntimeError(rr.error_message or 'Model verifier failed')
|
|
@@ -51,5 +57,5 @@ def verify_attempt(grader: GraderResult, outputs: ActualOutputs, trace: AgentTra
|
|
|
51
57
|
if settings.evaluation_mode == 'llm_required' or settings.llm_fail_closed:
|
|
52
58
|
raise
|
|
53
59
|
if _mentor_provider_can_attempt() and settings.llm_verifier_enabled and settings.evaluation_mode != 'deterministic_only':
|
|
54
|
-
pre.metadata_json.update({'model_verifier_enabled': True, 'llm_verifier_enabled': True, 'llm_unavailable': True, '
|
|
60
|
+
pre.metadata_json.update({'model_verifier_enabled': True, 'llm_verifier_enabled': True, 'llm_unavailable': True, 'role_status': 'mentor_verifier_unavailable', **artifact_preview_bundle})
|
|
55
61
|
return pre
|