Add token-budgeted observation delta (what changed)#375
Merged
Conversation
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.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 36 |
| Duplication | 1 |
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Adds
delta_observation/delta_index/summarize_delta— a compact, indexed, budget-capped "what changed since last step" summary for agent loops.observation.serialize_observationrenders one full frame (re-feeding it every turn blows the token budget the module exists to respect);element_diffgives 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 atmax_lines. Reuseselement_diff.match_elements(overlap join) +observation.observation_index(reading-order indexing). Pure-stdlib; Qt-free.Layers
utils/observation_delta/—delta_index,summarize_delta,delta_observation.je_auto_control+__all__.AC_delta_observation→{summary, added, removed, changed}.ac_delta_observation(read-only).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-enddelta_observation, full wiring + facade exports. 7 passed. ruff / bandit / radon / float-scan / Qt-free all clean.