agent-apprenticeship 0.1.9 → 0.2.1
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 +9 -3
- package/bin/agent-apprenticeship.js +96 -22
- package/docs/bioactive_evidence_mapping_schema.md +113 -0
- package/docs/dataset_schema.md +160 -0
- package/docs/local_usage.md +191 -0
- package/docs/scaling_to_1000_tasks.md +3 -0
- package/docs/trace_schema.md +192 -0
- package/docs/v0.2_release_notes.md +63 -0
- package/package.json +2 -1
- package/pyproject.toml +1 -1
- package/src/agent_apprenticeship_trace/__init__.py +1 -1
- package/src/agent_apprenticeship_trace/bundle_exporter.py +36 -1
- package/src/agent_apprenticeship_trace/cli.py +73 -12
- package/src/agent_apprenticeship_trace/config.py +1 -1
- package/src/agent_apprenticeship_trace/contract_verifier.py +686 -0
- package/src/agent_apprenticeship_trace/learning.py +203 -6
- package/src/agent_apprenticeship_trace/mentor_checkpoints.py +1 -1
- package/src/agent_apprenticeship_trace/public_run.py +31 -3
- package/src/agent_apprenticeship_trace/public_sanitizer.py +3 -3
- package/src/agent_apprenticeship_trace/tdo.py +1322 -43
- package/src/agent_apprenticeship_trace/trace_normalizer.py +25 -2
|
@@ -109,6 +109,30 @@ def _input_source(value: Any, meta: dict[str, Any]) -> dict[str, Any] | None:
|
|
|
109
109
|
meta["original_input_source"] = value
|
|
110
110
|
return None
|
|
111
111
|
|
|
112
|
+
def _actor_to_string(value: Any, action: str, meta: dict[str, Any]) -> str:
|
|
113
|
+
if action == "user_message":
|
|
114
|
+
return "user"
|
|
115
|
+
if isinstance(value, str) and value.strip():
|
|
116
|
+
return value.strip()
|
|
117
|
+
if isinstance(value, dict):
|
|
118
|
+
meta["original_actor"] = value
|
|
119
|
+
actor_kind = str(value.get("actor_kind") or value.get("kind") or "").strip()
|
|
120
|
+
role = str(value.get("role") or value.get("actor_role") or value.get("name") or "").strip()
|
|
121
|
+
agent_id = str(value.get("agent_id") or value.get("id") or "").strip()
|
|
122
|
+
if actor_kind and role:
|
|
123
|
+
return f"{actor_kind}:{role}"
|
|
124
|
+
if actor_kind and agent_id:
|
|
125
|
+
return f"{actor_kind}:{agent_id}"
|
|
126
|
+
if actor_kind:
|
|
127
|
+
return actor_kind
|
|
128
|
+
if role:
|
|
129
|
+
return role
|
|
130
|
+
if agent_id:
|
|
131
|
+
return f"agent:{agent_id}"
|
|
132
|
+
elif value is not None:
|
|
133
|
+
meta["original_actor"] = value
|
|
134
|
+
return "agent:worker"
|
|
135
|
+
|
|
112
136
|
def _infer_environment_domain(tool: Any, operation: Any = None, input_value: Any = None, output_value: Any = None) -> str:
|
|
113
137
|
text = " ".join(str(x or "") for x in [tool, operation, input_value, output_value]).lower()
|
|
114
138
|
if any(x in text for x in ["mcp__", "mcp ", "model context protocol"]):
|
|
@@ -714,8 +738,7 @@ def _normalize_step(raw_step: Any, ordinal: int, used_steps: set[int], report: T
|
|
|
714
738
|
if warnings:
|
|
715
739
|
meta['normalization_warnings']=warnings; report.warnings.extend(warnings)
|
|
716
740
|
|
|
717
|
-
actor=raw.get('actor')
|
|
718
|
-
if action == 'user_message': actor='user'
|
|
741
|
+
actor=_actor_to_string(raw.get('actor'), action, meta)
|
|
719
742
|
raw_execution_mode = raw.get('execution_mode') if raw.get('execution_mode') in {'serial','parallel'} else None
|
|
720
743
|
execution_mode = None if action == 'user_message' else (raw_execution_mode or 'serial')
|
|
721
744
|
parallel_group = _string_or_none(raw.get('parallel_group'), meta, 'parallel_group') if execution_mode == 'parallel' else None
|