Skip to content

Add token-budgeted observation delta (what changed)#375

Merged
JE-Chen merged 1 commit into
devfrom
feat/observation-delta-batch
Jun 23, 2026
Merged

Add token-budgeted observation delta (what changed)#375
JE-Chen merged 1 commit into
devfrom
feat/observation-delta-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

Adds delta_observation / delta_index / summarize_delta — a compact, indexed, budget-capped "what changed since last step" summary for agent loops. observation.serialize_observation renders one full frame (re-feeding it every turn blows the token budget the module exists to respect); element_diff gives the stable-ID correspondence but stops at matched/added/removed element pairs. This is the missing serializer that turns those into a model-ready delta.

It diffs the previous and current observation, classifies each matched element as changed (role/name/enabled/value/moved) or stable, and renders only the churn — + [i] role "name" (appeared) / - role "name" (vanished) / ~ [i] role "name" (fields) (changed) — added & changed first, stable dropped, capped at max_lines. Reuses element_diff.match_elements (overlap join) + observation.observation_index (reading-order indexing). Pure-stdlib; Qt-free.

Layers

  • Core: utils/observation_delta/delta_index, summarize_delta, delta_observation.
  • Facade: re-exported from je_auto_control + __all__.
  • Executor: AC_delta_observation{summary, added, removed, changed}.
  • MCP: ac_delta_observation (read-only).
  • Script Builder: Observation: Delta (what changed) under Native UI.
  • Docs: v163 EN + Zh + toctree. Changelog: root EN + zh-TW + zh-CN.

Tests

test/unit_test/headless/test_observation_delta_batch.py — added/removed/changed/stable classification, moved-is-a-change, summary markers + stable omitted, max_lines budget truncation with (+N more), end-to-end delta_observation, full wiring + facade exports. 7 passed. ruff / bandit / radon / float-scan / Qt-free all clean.

serialize_observation renders one full frame (blows the token budget every
turn); element_diff gives the stable-ID correspondence but stops at element
pairs. Add the missing serializer: diff two frames, classify matched elements
as changed or stable, render only the churn as +/~/- lines (added & changed
first, stable dropped, capped at max_lines). Reuses element_diff.match_elements
and observation.observation_index.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 36 complexity · 1 duplication

Metric Results
Complexity 36
Duplication 1

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit e28028d into dev Jun 23, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/observation-delta-batch branch June 23, 2026 19:07
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant