Repository navigation
feat!: collect observations only for mutating and batch tools - #61
Open
cryptotavares wants to merge 4 commits into
Conversation
Every tool call collected an observation (state, test IDs, a11y tree; on mobile also two device snapshots and an app-state query), even read-only and discovery tools whose response never included it. That work only fed the knowledge store, which is gone. - shouldCollectObservations: true only for mutating tools and run_steps (unless includeObservations is 'none'). shouldIncludeObservationsInResponse now builds on it, so the two rules cannot drift. - New 'cdp' tool category: cdp calls are mostly reads (Runtime.evaluate), so they no longer collect or return an observation. - accessibility_snapshot now resets the diff baseline, like describe_screen (both return the full tree). BREAKING CHANGE: readonly, discovery and cdp tools no longer collect observations. They no longer return `observations` (cdp did before), no longer refresh the session refMap through an observation, and no longer move the diff baseline for the next mutating call. A cdp call that changes state (e.g. Runtime.evaluate with a click) must be followed by describe_screen to get fresh refs. The public ToolCategory type gains 'cdp', so exhaustive switches on it need a new case.
cryptotavares
marked this pull request as ready for review
October 26, 2026 23:46
This branch has not been deployed
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.
Stack context: mm CLI v2, Phase 1, P1-05. Base: #60 (
cryptotavares/mmcli-p1-04-remove-knowledge-store); followed by #62. Review #60 first.Problem
The daemon collects observations after read-only and discovery calls, although their responses omit those observations. That work also refreshes refs and advances the diff baseline. The knowledge store that consumed it is gone after #60.
Raw
cdpcalls use themutatingcategory. A small result, such asRuntime.evaluate 1+1, therefore triggers and returns an additional observation. On mobile, observation collection queries app state and requests test IDs and an accessibility tree.Solution
Keep the policy at the shared HTTP executor. Tool handlers and platform drivers retain their existing responsibilities.
flowchart TD A[Queued tool finishes] --> B{Category and batch policy} B -->|readonly, discovery, cdp, or batch none| C[Skip observation collection] B -->|mutating or eligible batch| D{Active session?} D -->|yes| E[Collect observation through platform driver] D -->|no| C E --> F[Apply response inclusion policy] F -->|included| G[Compact against last observation] F -->|omitted| H[Return result and timing] C --> H G --> H classDef new fill:#fff3cd,stroke:#d39e00 class B,C,F newYellow boxes are new.
shouldIncludeObservationsInResponsecallsshouldCollectObservationsfirst. A shared batch-policy helper supplies the default, so collection and response inclusion use the same rule.The registry gives
cdpits own public category. CDP method execution stays in the platform driver. A state-changing CDP call needs a subsequentmm describe-screento refresh refs. Per-callobserveopt-in remains a P1-06 follow-up.accessibility_snapshotnow clears the diff baseline, likedescribe_screen,launch, andcleanup. The next collected mutation observation is full and compacted. Other read calls leave the baseline unchanged.What changes
readonlyordiscoverycallobservationMsis zerocdpcallmutating; collects and returns an observation when availablecdp; skips automatic collection and returns noobservationsrun_stepspolicyallby default;noneskips collection;failuresfilters the responsefailuresreturns observations only for a tool error or failed summaryaccessibility_snapshotfollowed by a mutationDecisions for reviewers
cdpto publicToolCategoryfailuresstill collects an observation and advances the baseline, but omits it from the response.Review guide
Read the files in this order:
src/tools/registry.tscdpcategory, tool assignment, and unchanged safe default for unknown tool names.src/server/create-server.tssrc/server/create-server.test.tssrc/tools/registry.test.tscdpclassification and registry/category coverage.README.md,SKILL.mdTesting
74b9819d26e4e1ff63b5a9be675a4b3cefd94e68:CI=true yarn vitest run src/server/create-server.test.ts src/tools/registry.test.ts src/tools/batch.test.ts src/tools/cdp.test.ts src/tools/discovery-tools.test.ts --coverage.enabled=false --maxWorkers=2 --minWorkers=1passes: 5 files, 181 tests.yarn lintpasses. Production type checking passes withyarn tsc --project tsconfig.build.json --noEmit.yarn tsc --project tsconfig.test.json --noEmitfails at the unchanged remote head with nine diagnostics. They affect the new timing-table callback and existing mobile-driver, network-mock, and screenshot tests. Vitest reports no type errors, but its result does not establish a clean explicit test-project type check.ProofandUnit testssections below retain the original historical evidence. These fresh checks do not repeat live-device validation.Breaking changes
readonly,discoveryandcdptools no longer collect observations. As a result:observations(cdpused to include them);cdpcall that changes state (for exampleRuntime.evaluatewith a.click()) must now be followed bydescribe-screento get fresh refs.ToolCategorytype gains'cdp'. Exhaustive switches on it need a new case.Consumer impact
test/e2e/playwright/llm-workflow/observations.tests/llm-workflow/Proof
Tested with a yalc build of this branch in the Extension (e2e build, headless) and in Mobile (dev client on iOS sim and Android emulator), on wallet home after unlock. Before = #60 tip (
0.12.0+f2caa574), after =0.12.0+ce3fd9f0. Ext was rechecked on the final commit (0.12.0+8a7091bf). Bench:scripts/bench.mjs, 5 runs (Android 3), p50.cdp Runtime.evaluate 1+1bytes, ext / iOS / Androidget-statetotalMs, ext / iOS / AndroidcdptotalMs, ext / iOS / Androidlist-testidstotalMs, ext / iOS / AndroidobservationMsforget-state,get-text,hermes-targets,list-testids,describe-screen,screenshot,accessibility-snapshot,cdpobservationskey), all platformsclick --testid unlock-submitobservations, ext / iOS / AndroidNotes from the proof run
toolMswent up in the after run (list-testidsp50 5975 → 11639 ms). This change does not touch discovery tools. The likely cause is variation in the ~1 MB Android a11y snapshot (the same area as the existinglist-testidstimeout). Totals still fell because observation time is now 0.wait-for,dismiss-keyboard) still hit the 8 s observation timeout and return noobservations. This already happened before the change (P1-04 build: iOSclick-unlock8003 ms).Transcripts (ext, final commit)
Unit tests
New or changed: per-category tests for
shouldCollectObservationsandshouldIncludeObservationsInResponse; endpoint tests forobservationMs(0 for readonly, discovery and cdp; > 0 for mutating); read tools don't move the diff baseline;accessibility_snapshotresets it; the cdp category in the registry.