Repository navigation
Fix Cursor native session normalization - #76109
Conversation
Co-authored-by: Copilot App <[email protected]>
|
❌ PR Specification Reviewer failed to deliver outputs. Please review the logs for details.
|
|
❌ Ponytail Reviewer failed. Please review the logs for details. Warning Threat detection engine error Threat detection could not complete its analysis due to a tooling error. This is not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs to troubleshoot the error.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
There was a problem hiding this comment.
Reviewed head d8e34eb against Unified Agent Session Specification v2.7.0, especially T-UAS-005, T-UAS-006, T-UAS-007, T-UAS-012–015, and T-UAS-020. The implementation is aligned with the existing normative preservation, metadata, timestamp, tool, result, and usage obligations. The PR makes prior informative Cursor coverage statements stale: sanitized stream-json live-shape evidence is now present, while live failed-tool, subagent, and latest-release coverage remains unverified. I synchronized docs/src/content/docs/specs/unified-agent-session-specification.md to draft v2.7.1 (2026-11-09), updating Sections 7.9, 9.4, 9.6, and the change log without changing normative requirements. The specification commit is queued for publication on this PR branch. No blocking conformance finding identified. Coverage is static: no tests or workflows were executed by this review.
Generated by PR Specification Reviewer for #76109 · copilot · gpt50 · ~5 AIC · ⌖ ~2 AIC · ⊞ 1.7K
Comment /review-specs to run again
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
I found three correctness issues that can silently lose session data or crash usage normalization.
Findings
- Cache alias selection stops at the first present, even invalid, alias.
- Unknown overflow markers can now throw during normalization.
- Session-wide answer deduplication can drop a legitimate repeated terminal answer and its correlation.
Please address these edge cases before merge.
Comments that could not be inline-anchored
actions/setup/js/agent_session.cjs:79
This alias lookup can discard valid cache evidence when an earlier alias is present but invalid, causing cache accounting to disappear. <details><summary>💡 Prefer the first valid alias</summary> `find` currently selects the first present alias, not the first alias whose value passes `isTokenCount`; for example, `{cacheReadTokens: "bad", cache_read_tokens: 5}` yields no canonical cache count. Select the first valid alias (or continue searching after invalid values), while preserving canonical-...
actions/setup/js/agent_session.cjs:146
This loop now throws when `overflowed_tokens` contains an unknown key, turning malformed or stale usage metadata into a parser crash. <details><summary>💡 Ignore or validate unknown overflow keys</summary> `USAGE_ALIASES[key]` is undefined for foreign keys, so `for (const alias of USAGE_ALIASES[key])` raises `TypeError`. The previous single-property delete was harmless. Guard with an own-key check or iterate `(USAGE_ALIASES[key] ?? [])` so unknown overflow markers remain non-fatal. </details>
actions/setup/js/agent_session.cjs:251
This session-wide text search can suppress a legitimate terminal answer when an earlier assistant turn used the same content, losing the final result and its request correlation. <details><summary>💡 Scope deduplication to the current result</summary> The `some` predicate matches any prior `assistant.message` with equal text and also treats two missing session IDs as equal. Deduplicate only the message produced by the same model/request or the immediately preceding normalized event, so repeate...
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
There was a problem hiding this comment.
🟡 Changes recommended
Cursor omits separate cache usage from session totals, and rejected cache values can reappear in token accounting through lower-priority aliases.
2 open issues
What changed in this PR
This PR corrects Cursor native-log normalization in gh-aw, preserving session evidence without changing the engine version, credentials, or inference behavior.
Changes:
- Filters tool metadata and normalizes reasoning, timestamps, correlations, and distinct terminal answers.
- Adds cache-token aliases with validation and overflow handling.
- Adds regression coverage, updates sample documentation, and regenerates both Cursor workflow locks.
| File | Description |
|---|---|
pkg/workflow/cursor_workflow_test.go |
Adds native Cursor event and unified-projection regressions. |
actions/setup/js/agent_session.test.cjs |
Tests cache aliases, precedence, validation, and overflow. |
actions/setup/js/agent_session.cjs |
Extends shared usage normalization with native cache aliases. |
.github/workflows/smoke-cursor.lock.yml |
Regenerates the smoke workflow with parser updates. |
.github/workflows/shared/cursor.md |
Updates the Cursor parser and documents evidence coverage. |
.github/workflows/engine-conformance-cursor.lock.yml |
Regenerates the conformance workflow with parser updates. |
.changeset/patch-cursor-session-normalization.md |
Records the normalization fixes as a patch release. |
Review effort: Balanced (auto)
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /tdd. Requesting changes because the shared usage normalizer can drop a valid token count.
📋 Findings and notes
Blocking
- Alias precedence (
agent_session.cjs:79): the lookup picks the first present alias, so an invalid camelCase value hides a valid alias. Reproduced on HEAD. Fix: select byisTokenCount. - Latent throw (
agent_session.cjs:101,124,146): non-canonical overflow keys makeUSAGE_ALIASES[key]undefined. Current callers appear sanitized, so this is not blocking, but the?? []guard is cheap.
Non-blocking
- Dedup scope (
cursor.md:260): theresultfallback matches only on content, so sessionless runs can suppress a repeated final answer. - Tool filter: non-
*ToolCallnative tool shapes now fall through tocursor.tool_call. Confirm this is intended and add a test. - Integration dependency:
messageIdretention in the final tool projection depends on the Pi shared projection change. Confirm that lands with this PR.
Positive
- ✅ Lock files match the source parser at HEAD.
- ✅ The changeset is an accurate patch entry.
- ✅ The
assistant.reasoningmapping and timestamp validation are covered by tests.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~2 AIC · ⊞ 6.3K
Comment /matt to run again
Sync main snapshot 1b6cb00, preserving Cursor fixes and regenerated workflow/session artifacts. Co-authored-by: Copilot App <[email protected]>
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "5a4bfc454b2801ceea49405d8aa3d562101fea71",
"kind": "requested",
"schema_version": "1",
"state": "2b96c5f971a786fa50c4cf32a07bea070e06d28466ee058e4b9338b1c5ac7ef7",
"work": [
"037d198a8d5660bee26f6ba2e058650cf480f9c3462849ee56d886a5bacbcdb8",
"a5012a56d74f24ce98e98ecb961e5db0755b5cc2d941045b7e46cf860431eb63",
"cd03f182e3412dfcaeee297635f941393b25d83c9a54012da21666f3f9bad70f"
],
"workflow": "pr-sous-chef"
}
|
Include separate cache usage in Cursor totals, prevent invalid alias resurrection, normalize overflow markers safely, and scope terminal-answer deduplication. Co-authored-by: Copilot App <[email protected]>
|
In reply to the specification reviewer status: I inspected the failed step. The agent completed, but publishing its specification patch was blocked because the workflow token could not read branch-protection metadata; I am keeping that permission failure separate from the Cursor fixes and have not changed credentials or bypassed the protection. |
|
In reply to the Ponytail reviewer status: The failed step was secret redaction, which removed the artifact and failed closed with ERR_VALIDATION. This is unavailable reviewer evidence, not a security finding; I have not weakened redaction or rerun the workflow. |
|
In reply to the code quality review status: I addressed the resulting alias-validation, overflow-key and terminal-answer feedback with focused regressions. Presence-based alias precedence remains intentional, so the contradictory suggestion to substitute a lower-priority valid value is declined explicitly in its inline thread. |
|
In reply to the design decision gate: No additional design change is requested by this reported_no_action notice. The fixes preserve the existing canonical session contract; I am not treating the no-op status as proof of runtime completeness. |
|
In reply to the test quality status: The review notices require no independent code change, but the concrete feedback is now covered by cache-total, alias-rejection, hostile overflow-key and scoped terminal-answer regressions. The reported_no_action status is not being used as a substitute for those checks. |
|
In reply to the skills review status: I fixed overflow safety and terminal-answer scoping, and added regressions for the native tool-shape boundary and cache accounting. The first-valid alias suggestion is declined because it contradicts property-presence precedence and can resurrect explicitly rejected usage; tool messageId projection remains a separately tracked Pi integration dependency. |
|
In reply to the saved review themes: The matching findings are addressed by rejected-alias cleanup, guarded overflow processing and tighter terminal-answer deduplication, with regressions. I have left the workflow-managed comment-memory block unchanged. |
Merged latest |
|
🎉 This pull request is included in a new release. Release: |


Summary
Fix the concrete Cursor normalization defects observed in the existing conformance run, without changing the pinned engine version, credentials, or inference behavior.
hookAdditionalContextsand other metadata from tool execution events; preserve unknown observations as opaque Cursor events rather than fabricating calls.Evidence and validation
Local replay of the downloaded conformance log now produces 6 tool starts, 6 completions, 43 reasoning events, 57 native timestamps, zero phantom hook tools, and preserves 95,360 cache-read tokens, zero cache-write tokens, and the distinct terminal answer. This is local replay of existing evidence, not a newly executed Actions run.
Passed:
make build && make fmtmake lint-cjs(no errors; existing repository warnings remain)make recompile— all 365 workflows compiledgo test ./pkg/workflow -run '^TestCursor' -count=1typecheck, session schema freshness, and 542 focused JavaScript tests covering session normalization, usage, ordering, rendering and telemetrymake agent-report-progresstest groups passed. Its Go lint hit another session's global linter lock; all remaining non-test gates passed onmake agent-report-progress-no-testwith a privateTMPDIR, including Go lint and full workflow drift validation.test-unitwas not rerun.Integration dependency / unverified coverage
The adapter emits tool
messageIdcorrelations. Their retention in the final unified tool projection depends on the separately owned Pi shared-projection fix; this PR deliberately does not duplicate that shared ownership. Assistant model-call/request correlations already survive the existing projection.No new workflow dispatch, inference, MCP startup, or credential change was performed. The recent smoke run stopped on an invalid API key and provides no structured runtime coverage. Failed-tool and subagent mapping remain unverified live where absent from the captured evidence; these historical runs are not rewritten.