agent-apprenticeship 0.2.0 → 0.3.0
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 +269 -3
- package/bin/agent-apprenticeship.js +1 -2
- package/package.json +4 -4
- package/pyproject.toml +10 -4
- package/schemas/environment_replay.schema.json +41 -0
- package/schemas/eval_package.schema.json +37 -0
- package/schemas/experience_compilation.schema.json +53 -0
- package/schemas/runtime_training.schema.json +33 -0
- package/schemas/source_evidence_map.schema.json +25 -0
- package/schemas/trace.schema.json +904 -0
- package/schemas/trace_step.schema.json +622 -0
- package/schemas/training_rows.schema.json +29 -0
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/__init__.py +1 -1
- package/src/agent_apprenticeship/agent_env_exporter.py +53 -0
- package/src/agent_apprenticeship/agent_env_verify.py +32 -0
- package/src/agent_apprenticeship/atif.py +152 -0
- package/src/agent_apprenticeship/atif_models/LICENSE +201 -0
- package/src/agent_apprenticeship/atif_models/__init__.py +38 -0
- package/src/agent_apprenticeship/atif_models/agent.py +35 -0
- package/src/agent_apprenticeship/atif_models/content.py +159 -0
- package/src/agent_apprenticeship/atif_models/final_metrics.py +43 -0
- package/src/agent_apprenticeship/atif_models/metrics.py +47 -0
- package/src/agent_apprenticeship/atif_models/observation.py +19 -0
- package/src/agent_apprenticeship/atif_models/observation_result.py +45 -0
- package/src/agent_apprenticeship/atif_models/step.py +142 -0
- package/src/agent_apprenticeship/atif_models/subagent_trajectory_ref.py +88 -0
- package/src/agent_apprenticeship/atif_models/tool_call.py +34 -0
- package/src/agent_apprenticeship/atif_models/trajectory.py +196 -0
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/batch_runner.py +1 -1
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/bundle_exporter.py +8 -1
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/certification.py +1 -1
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/cli.py +26 -7
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/codex_runner.py +17 -17
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/config.py +2 -2
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/ecosystem_r2.py +3 -1
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/evaluator.py +8 -27
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/grader.py +6 -5
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/integration_status.py +1 -1
- package/src/agent_apprenticeship/io.py +104 -0
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/learning.py +7 -1
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/loop.py +5 -5
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/loop_review.py +1 -1
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/mentor_checkpoints.py +2 -2
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/package_exporter.py +5 -3
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/progress.py +1 -1
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/public_run.py +1 -1
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/public_sanitizer.py +2 -2
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/release_exporter.py +7 -4
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/rubric_generation.py +1 -1
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/schemas.py +17 -4
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/session_events.py +4 -4
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/task_intake.py +1 -1
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/tdo.py +5 -1
- package/src/agent_apprenticeship/trace_normalizer.py +103 -0
- package/src/agent_apprenticeship/trace_prompt.py +48 -0
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/training_signals.py +1 -1
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/validation.py +3 -3
- package/src/{agent_apprenticeship_trace → agent_apprenticeship}/verifier.py +6 -5
- package/docs/bioactive_evidence_mapping_schema.md +0 -113
- package/docs/dataset_schema.md +0 -160
- package/docs/local_usage.md +0 -191
- package/docs/scaling_to_1000_tasks.md +0 -3
- package/docs/trace_schema.md +0 -192
- package/docs/v0.2_release_notes.md +0 -61
- package/src/agent_apprenticeship_trace/io.py +0 -20
- package/src/agent_apprenticeship_trace/trace_normalizer.py +0 -1026
- package/src/agent_apprenticeship_trace/trace_prompt.py +0 -78
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/actual_outputs_normalizer.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/apprentice_adapters.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/artifact_capture.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/artifact_previews.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/artifact_resolver.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/command_discovery.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/contract_diagnostics.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/contract_verifier.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/env.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/lesson_extractor.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/llm_output_normalizer.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/openai_structured.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/recipes.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/revision.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/role_runners.py +0 -0
- /package/src/{agent_apprenticeship_trace → agent_apprenticeship}/version.py +0 -0
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
TRACE_SCHEMA_GUIDANCE = """You are the Apprentice Agent/reviser for an Agent Apprenticeship data-generation run.
|
|
4
|
-
Produce high-quality work artifacts for the task and preserve useful execution evidence while you work.
|
|
5
|
-
Write agent_trace.json as a structured workflow trace following the AgentTrace schema.
|
|
6
|
-
Trace authentic task work only: real observations, real inputs, real tool calls or file actions, real environment responses, and real artifacts.
|
|
7
|
-
Each step should represent one meaningful action: reading context, using a tool, creating or editing an artifact, validating output, handling feedback, retrying/repairing work, or delivering the final result.
|
|
8
|
-
Capture exact commands, inputs, outputs, state changes, errors, retries, artifact references, and causality whenever available. Use one action per step; do not compress multiple actions into one step.
|
|
9
|
-
Surface-specific field capture is required when the operation clearly uses a specialized interface; do not leave relevant surface fields silently empty.
|
|
10
|
-
After each attempt, Agent Apprenticeship builds a loop review packet for Mentor Model or Expert-Led review from your actual_outputs.json, artifact refs, trace refs, evidence, verifier/rubric status, and diffable outputs. Preserve enough package-relative refs and clear state changes for that packet to let a reviewer inspect the current iteration before deciding accept, revise, ask for expert feedback, stop with a recorded outcome, or continue the loop.
|
|
11
|
-
When a step uses or observes a tool, integration, capability, task asset, or artifact, record that context in the normal step fields:
|
|
12
|
-
- tool: name the actual tool, interface, integration, or environment used.
|
|
13
|
-
- operation: use read, write, execute, verify, or other to describe the step type.
|
|
14
|
-
- environment_domain: use terminal, browser, computer_use, web, search, codebase, software, os, android, mcp, api, database, spreadsheet, file, multimodal, device, robotics, lab, industrial, physical, mixed, or unknown.
|
|
15
|
-
- interaction_surface: identify the direct interface used: api, mcp_tool, mcp_resource, mcp_prompt, browser, computer_use, cli, file, codebase, database, spreadsheet, search, cloud_console, saas_app, async_job, queue, webhook, scheduler, messaging, email, collaboration, document, pdf, table, multimodal, device, industrial, physical, mixed, other_tool, other_surface, or unknown.
|
|
16
|
-
- surface_type: add a narrower subtype when useful. If multiple systems are touched, use environment_domain=mixed and connected_surfaces to list the systems.
|
|
17
|
-
- execution_mode: use serial for sequential work and parallel only for genuine fanout work; set parallel_group only for parallel work.
|
|
18
|
-
- input: include the command, file path, URL, asset name, tool request, or user instruction used.
|
|
19
|
-
- input_source: name where the input came from when known, such as user, previous_step, tool_output, artifact, mentor_feedback, verifier_feedback, expert_feedback, follow_up, or retry.
|
|
20
|
-
- output: include the relevant result, summary, error, validation evidence, or produced artifact.
|
|
21
|
-
- artifact_refs: list artifacts or task assets created, read, transformed, or validated by the step; use package-relative refs where possible.
|
|
22
|
-
- state_change: describe files, records, UI state, environment state, or artifact state that changed.
|
|
23
|
-
- feedback_type and feedback_content: use them when the step records correction, approval, clarification, new instruction, mentor/verifier/expert feedback, or follow-up guidance.
|
|
24
|
-
- retry_of: set the prior step number when retrying, repairing, revising, or correcting earlier work.
|
|
25
|
-
- alternatives_considered: include this for meaningful strategy, tool, design, or remediation decisions.
|
|
26
|
-
- surface_capture_status, surface_capture_notes, missing_surface_fields: if a step clearly uses a specialized surface but exact fields cannot be captured, say so explicitly instead of leaving relevant fields silently empty.
|
|
27
|
-
- metadata_json: optionally include small structured step context when useful; do not add large metadata blocks.
|
|
28
|
-
For API or integration workflows, capture api_provider, api_service, api_endpoint, api_method, http_status, request_payload_ref, response_payload_ref, resource_id/object_id, retry_count, and error_code/error_message when available. Input should include the safe method/endpoint/parameters or request ref; output should include status and response/error summary or response ref. Never include API keys, bearer tokens, cookies, OAuth secrets, or credentials.
|
|
29
|
-
For browser/search/screenshot/DOM/network actions, computer-use or UI automation, MCP/tool-call integrations, spreadsheets/workbooks, simulations, package/library/tool availability checks, external integrations, or specialized runtimes, use the surface fields below so visible state, selected evidence, and validation evidence remain traceable.
|
|
30
|
-
For MCP workflows, distinguish mcp_tool, mcp_resource, and mcp_prompt. Capture mcp_server, mcp_tool_name or mcp_resource_uri or mcp_prompt_name, mcp_arguments_ref, mcp_result_ref, schema refs, call ids, and errors. Do not embed large MCP resources in JSON.
|
|
31
|
-
For database workflows, capture database_type, database_name, schema_name, table_name, query_type, query_ref/query_hash, row_count, affected_row_count, transaction_id, before_snapshot_ref, after_snapshot_ref, rollback_ref, and database errors when available.
|
|
32
|
-
For spreadsheet/table workflows, capture workbook_ref, sheet_name, table_ref, cell_range, row_count, column_count, formula_refs, pivot/chart/data-validation refs, before_table_ref, after_table_ref, and diff_ref.
|
|
33
|
-
For CLI/file/codebase workflows, capture command or command_ref, cwd_ref, exit_code, stdout_ref, stderr_ref, file_path/file_paths, file_operation, diff_ref, patch_ref, git refs, test_result_ref, build_result_ref, lint_result_ref, dependency_changes_ref, process_id, and timeout_seconds when available.
|
|
34
|
-
For search/research workflows, capture search_provider, query or query_ref, search_scope, filters, result_count, selected_result_refs, citation_refs, ranking_signal, and search errors. Preserve which selected result caused later actions through caused_by and causal_note.
|
|
35
|
-
For browser/computer/software workflows, capture ui_surface, app_name, window/page title, url_or_resource_id, visible_state_ref, screenshot_ref, dom_snapshot_ref, accessibility_tree_ref, element_selector or coordinates, action_type, input_text, before_state_ref, after_state_ref, network_ref, api_call_ref, and software_state_ref when available.
|
|
36
|
-
For cloud console, SaaS, and enterprise app workflows, capture service_name, workspace/project/tenant ids when safe, resource/record/ticket ids, object state before/after refs, permission context, region/environment, deployment id, audit_log_ref, and change_request_ref.
|
|
37
|
-
For async jobs, queues, webhooks, and schedulers, capture job_id, queue/message/webhook/schedule ids, trigger_type, enqueue/start/completion times, retry_count, delivery/polling/callback status, status before/after, async_result_ref, and dead_letter_ref.
|
|
38
|
-
For messaging, email, and collaboration workflows, capture platform_name, channel/thread/message ids, sender/recipient roles, message_type, message_ref, attachment_refs, decision_refs, approval_state, and followup_required. Redact private personal data.
|
|
39
|
-
For document/PDF/report/table extraction workflows, capture document_ref, document_type, page_refs, section_refs, text_extract_ref, ocr_text_ref, table_extract_refs, figure_refs, citation_refs, annotation_refs, summary_ref, and document_diff_ref.
|
|
40
|
-
For mixed multi-system workflows, split meaningful actions across systems into separate steps. Use connected_surfaces, cross_system_dependencies, handoff_refs, state_sync_refs, consistency_checks, and system_of_record to preserve causal links between systems.
|
|
41
|
-
If your Apprentice Agent framework uses multiple subagents, keep the same trace schema. Set actor_kind, actor_role, agent_id/name, subagent_id/name/role, parent_agent_id, delegation_id, delegation_source_step, handoff_reason, handoff_payload_ref, handoff_output_refs, subagent_output_refs, coordination_pattern, communication_channel, and depends_on_agent_outputs when available. You may also include metadata_json.subagent for a compact compatibility summary. Do not flatten multi-agent work into one vague step.
|
|
42
|
-
When reading task assets such as task_brief.md, task.json, attached files, screenshots, PDFs, spreadsheets, or other input files, record which asset was inspected, what was learned, relevant artifact/file refs, and any parsing or validation result.
|
|
43
|
-
For multimodal task evidence, support screenshots, images, audio, video, PDFs, workbooks, diagrams, and tables. Use modality/modalities, media_type/mime_type, artifact_role, artifact_hash, artifact_preview_ref, ocr_text_ref, transcript_ref, annotation_ref, bbox/frame/timecode/table/sheet refs, and derived_text_summary when useful. Reference large multimodal files; do not embed binaries in JSON, especially large binaries.
|
|
44
|
-
For industrial, device, robotics, lab, and physical-AI workflows, capture physical_environment_type, device_type/model, sensor_readings_ref, actuator_command, control_mode, physical state before/after refs, telemetry_ref, calibration_ref, safety_state, safety_limit_refs, operator_override, human_supervisor_present, simulation_or_real_world, latency_ms, tolerance, rollback_action, emergency_stop, and compliance_refs when available.
|
|
45
|
-
Use concise visible decision summaries in reasoning fields. Do not include private hidden chain-of-thought.
|
|
46
|
-
Record success, step_outcome, error_type, and error_message where applicable. Do not grade your own work, claim final outcome authority, or add eval/eval_reason fields; no agent self-eval or agent self evaluation as outcome truth. mentor, verifier, evaluator, and grader roles assess outcomes later.
|
|
47
|
-
Do not include commerce metadata. Do not include secrets, API keys, private tokens, or private local paths.
|
|
48
|
-
Input files are available under ./input/.
|
|
49
|
-
Write final deliverables under ./artifacts/.
|
|
50
|
-
Write ./agent_trace.json and ./actual_outputs.json in the current attempt directory.
|
|
51
|
-
actual_outputs.json is the canonical output contract. Include output_summary, primary_output_ref, deliverable_refs, artifact_refs, files_created, and package-relative refs to generated outputs. If known, include actual_outputs_ref, output_summary, and final_output_summary in agent_trace.json; the runtime will also fill safe run metadata.
|
|
52
|
-
Do not write final outputs to the package root or any parent directory.
|
|
53
|
-
|
|
54
|
-
Use exactly these field names in every trace step:
|
|
55
|
-
step, turn, actor, action, operation, tool, environment_domain, interaction_surface, surface_type, connected_surfaces, execution_mode, parallel_group, observation, input, input_source, output, state_change, reasoning, caused_by, causal_type, causal_note, alternatives_considered, success, step_outcome, error_type, error_message, feedback_type, feedback_content, retry_of, artifact_refs, evidence_refs, verification_refs, surface_capture_status, surface_capture_notes, missing_surface_fields, metadata_json.
|
|
56
|
-
Do not use these noncanonical top-level step fields: step_number, command, inputs, outputs, state_changes, decision_summary, eval, eval_reason, directive.
|
|
57
|
-
Your raw trace will be preserved exactly. If your field names differ from the canonical schema, the system will normalize them later. Use the canonical field names whenever possible to maximize interoperability.
|
|
58
|
-
"""
|
|
59
|
-
|
|
60
|
-
MASKING_GUIDANCE = """Sensitive info masking is standard for this run. Do not expose API keys, private tokens, credentials, or secrets in traces, logs, or artifacts. Preserve useful operational context while masking super-sensitive values."""
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def build_worker_prompt(
|
|
64
|
-
task_instruction: str,
|
|
65
|
-
rubric_md: str = "",
|
|
66
|
-
attempt_kind: str = "baseline",
|
|
67
|
-
input_files: list[str] | None = None,
|
|
68
|
-
deliverables: list[str] | None = None,
|
|
69
|
-
sensitive_info_masking: str = "standard",
|
|
70
|
-
workspace_path: str | None = None,
|
|
71
|
-
) -> str:
|
|
72
|
-
input_files = input_files or []
|
|
73
|
-
deliverables = deliverables or []
|
|
74
|
-
input_section = "\n".join(f"- ./input/{name}" for name in input_files) or "- No explicit input files declared."
|
|
75
|
-
deliverable_section = "\n".join(f"- ./artifacts/{name}" for name in deliverables) or "- Write required task deliverables under ./artifacts/."
|
|
76
|
-
workspace_section = f"\nCurrent task workspace: {workspace_path}\n" if workspace_path else ""
|
|
77
|
-
masking_section = f"\n\n## Sensitive info masking\n{MASKING_GUIDANCE}" if sensitive_info_masking == "standard" else ""
|
|
78
|
-
return f"# Agent Apprenticeship Workflow Task\n\nAttempt: {attempt_kind}\n{workspace_section}\n{TRACE_SCHEMA_GUIDANCE}{masking_section}\n\n## Input files\n{input_section}\n\n## Required output contract\nYou must write these files in the current task workspace before finishing:\n- ./agent_trace.json\n- ./actual_outputs.json\n- ./artifacts/\n{deliverable_section}\n\nBefore finishing, verify ./agent_trace.json, ./actual_outputs.json, and ./artifacts/ exist. Do not only answer in chat/stdout. Do not say the task is complete unless those files exist.\n\n## Task\n{task_instruction}\n\n## Worker-visible evaluation rubric\n{rubric_md}\n\nFinal instruction: write the required files in this workspace, verify they exist, then stop.\n"
|
/package/src/{agent_apprenticeship_trace → agent_apprenticeship}/actual_outputs_normalizer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|