|
| 1 | +Per-Step Critic Features + Rule-Based Step Scorer |
| 2 | +================================================= |
| 3 | + |
| 4 | +Scoring an agent's step needs the evidence in one place — what the action was, what changed, |
| 5 | +whether it landed on target, whether the declared postcondition held. ``trajectory_eval`` |
| 6 | +scores a *finished whole trajectory* against a static rubric and has no per-step evidence; |
| 7 | +``agent_trace`` emits OTel spans (tokens / latency), not decision quality; ``agent_replay`` |
| 8 | +persists ``{obs, action, result}`` but does no scoring. ``critic_features`` is the missing |
| 9 | +per-step layer: it composes ``action_effect`` (did it do anything, where), |
| 10 | +``observation_delta`` (how much changed) and ``postcondition`` (did the expected outcome hold) |
| 11 | +into one compact record, and ships a deterministic rule-based scorer so the feature works fully |
| 12 | +headless — leaving the optional LLM-as-judge to the integrator. |
| 13 | + |
| 14 | +Pure-stdlib; composes existing pure modules; deterministic and unit-testable with no device. |
| 15 | +Imports no ``PySide6``. |
| 16 | + |
| 17 | +Headless API |
| 18 | +------------ |
| 19 | + |
| 20 | +.. code-block:: python |
| 21 | +
|
| 22 | + from je_auto_control import (build_critic_record, score_step_rule_based, |
| 23 | + to_judge_prompt) |
| 24 | +
|
| 25 | + record = build_critic_record({"type": "click", "x": 480, "y": 260}, |
| 26 | + before_elements, after_elements, |
| 27 | + postcondition={"appears": {"role": "dialog"}}) |
| 28 | + score = score_step_rule_based(record) |
| 29 | + # {"outcome": True, "process_score": 1.0, "reasons": [...]} |
| 30 | +
|
| 31 | + prompt = to_judge_prompt(record) # compact text for an LLM-as-judge |
| 32 | +
|
| 33 | +``build_critic_record`` returns ``{action, effect, delta_counts}`` plus a ``postcondition`` |
| 34 | +report when a spec is given. ``score_step_rule_based`` returns ``{outcome, process_score, |
| 35 | +reasons}`` — ``outcome`` is a binary success (the action did something *and* any postcondition |
| 36 | +held), ``process_score`` is a 0..1 quality from the effect class (halved if the postcondition |
| 37 | +failed). ``to_judge_prompt`` renders the record for an external judge. |
| 38 | + |
| 39 | +Executor commands |
| 40 | +----------------- |
| 41 | + |
| 42 | +``AC_build_critic_record`` (``action`` / ``before`` / ``after`` / ``postcondition`` / |
| 43 | +``radius`` → the record) and ``AC_score_step`` (``record`` → ``{outcome, process_score, |
| 44 | +reasons}``). They are exposed as the MCP tools ``ac_build_critic_record`` / ``ac_score_step`` |
| 45 | +(read-only) and as the Script Builder commands **Build Critic Record** / **Score Step |
| 46 | +(rule-based)** under **Native UI**. |
0 commit comments