Skip to content

fix!: preserve address context input errors - #8419

Merged
morluto merged 4 commits into
mainfrom
codex/context-input-errors
Nov 1, 2026
Merged

morluto merged 4 commits into
mainfrom
codex/context-input-errors

Conversation

@morluto

@morluto morluto commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

inspect_address_context can successfully return other facets while a provider rejects one caller input, but it currently discards that facet's typed error and issue details. Preserve the canonical invalid_request projection on that unavailable facet so the agent can see the rejected field and diagnostic without repeating the operation.

Addresses #8415. Builds on #8417, now merged into main: an input error with incomplete cleanup remains a top-level cleanup failure. Draft #8414 also touches the workflow and verifier; a detached combination has been tested. Draft #8424 is stacked on this PR for a separate resource-capacity recovery case.

Change and scope

The context workflow projects the original AnalysisInputError through REA's existing error owner. Its unavailable facet carries the canonical error, projected message and recovery; successful siblings remain intact. For example, an unavailable name facet now includes error.code: "invalid_request" and error.details.issues, while an available function facet stays available. Other failure types keep their current behavior. The shared canonical invalid_request schema is reused in both context-facet schemas. No new address grammar, implicit document selection, provider retry, or reclassification of a local input failure as a whole-request failure is introduced. This is a read-only workflow fix within existing scope; no new-capability maintainer decision is applicable.

Contract and boundary impact

  • Breaking for strict clients caching the prior full MCP output schema: unavailable facets can now include error. Refresh tools/list after upgrading and accept the newly advertised schema. Ajv 2020 rejected a real new result against the old full schema and accepted it against the old compact schema; both newly advertised profiles accepted it. No compatibility shim is added.
  • The aggregate may still return success when every attempted facet fails. The typed error is attached to each rejected facet; other provider failures and [Design] Preserve contributing evidence for address-context handoffs #8364's aggregate Evidence handoff remain separate work.
  • Exact diagnostics are retained, which can duplicate common provider diagnostics across facets. No output is silently truncated or reconstructed by retrying the provider.

Evidence and regression coverage

Real Ghidra 12.1.4 and Kuna 1.986 MCP controls used an unexecuted source-owned arm64 Mach-O. With a wrong document or malformed address, the nested name-facet error retained the same typed issues as the corresponding direct call; the valid-document/address control matched baseline. Both compact and full fetched output profiles were exercised. The target digest was unchanged. The real-Ghidra COM verifier also exercises both rejected inputs through the public SDK and checks the provider-owned issue details.

Controlled MCP tests cover partial success, conformsToInputContract true/false, comment and bookmark failures, both schema profiles, non-input facet failure, and cleanup precedence. Five new mixed-facet cases failed against the #8417 parent and passed with this change. The cleanup case uses a simulated error, not a real provider cleanup failure.

Token and size observations

These are measurements of minified JSON payloads using o200k_base, not a latency, CPU, memory, or autonomous-agent study. On the single Ghidra wrong-document fixture, the context result increased from 225 to 1,881 tokens because two facets each retain full provider diagnostics. The old context result plus one separately issued direct-name error totaled 1,012 tokens, excluding both call inputs; the later retry is not proof of the original observation. The complete tools/list payload increased from 125,362 to 125,379 tokens in compact mode and from 1,040,344 to 1,040,726 in full mode; these are whole-catalog JSON counts for this local tool inventory. Exact costs depend on paths, diagnostics, client presentation and tokenizer. Response-budget overflow for unusually large diagnostics was not exercised. #8364 remains open for a retained aggregate/source-Evidence design that could make a smaller inline response practical without losing the original diagnostics.

Validation performed

Latest merge resolution (527730ddf, merging main at d684125ee): the only conflict was the import block in AnalysisContextQueries.ts; the resolved file is unchanged from the prior PR head. The three focused address-context test files passed (43 tests), along with npm run check:fast, npm run docs:check (including 9 README consistency tests), resolved-file formatting, and git diff --check. Real-provider verification below is prior evidence and was not repeated for this merge.

  • npm run test:focused -- tests/boundary/mcp/addressContextInputErrors.test.ts tests/boundary/mcp/addressContextBookmarks.test.ts — 15 passed. After the review-only test import change, the six input-error tests and npm run check:fast passed again; production code was unchanged.
  • npm run verify:ghidra:com — passed with real Ghidra 12.1.4/JDK 21 on macOS arm64, including the new input-error controls; no target execution, source unchanged and owned processes cleaned up.
  • Real Ghidra and Kuna stdio MCP wrong-document, malformed-address and valid controls under compact and full advertised schemas — passed as described above.
  • Ajv 2020 actual-result and invalid-code controls — new full schema accepts the real result and rejects a wrong code; compact schema is intentionally broad.
  • npm run check:fast, npm run docs:check, git diff --check and changed-file formatting check — passed.
  • Detached fix: guide address-context comment recovery #8414 + fix: retain address context cleanup failures #8417 + this change: 20 MCP boundary tests and the real-Ghidra COM verifier passed, including both the input-error and comment-recovery controls.

Compatibility, safety, and release

BREAKING CHANGE: A client retaining an older strict full output schema can reject the added facet field. Refresh the MCP catalog and validate against the current advertised schema. Other providers, Windows, real cleanup failures, unusually large diagnostics and autonomous agent behavior are unverified.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

BREAKING CHANGE: Strict clients that cached the previous full inspect_address_context output schema must refresh tools/list and accept the typed error field on unavailable facets.
@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge within its documented compatibility change.

Summary

inspect_address_context now retains canonical input errors on unavailable facets while preserving successful siblings.

  • Address context results keep rejected input errors beside successful facets.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Inspect explicit address] --> B[Run provider facets]
  B --> C{Cleanup or request-level failure?}
  C -->|Yes| D[Return top-level error]
  C -->|No| E{Facet outcome}
  E -->|Success| F[Available value]
  E -->|Input refusal| G[Unavailable with canonical error]
  E -->|Other failure| H[Existing unavailable outcome]
  F --> I[Return combined context]
  G --> I
  H --> I
Loading

Reviews (3) · Last reviewed commit: "chore: resolve main merge conflict for a..." · Reviewed by Greptile

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T13:19:22.945468Z 527730d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Base automatically changed from codex/context-cleanup-ownership to main November 1, 2026 09:24
@morluto
morluto merged commit 3e6a5cb into main Nov 1, 2026
50 of 52 checks passed
@morluto
morluto deleted the codex/context-input-errors branch November 1, 2026 16:52
coyoteXujie pushed a commit to coyoteXujie/rea that referenced this pull request Nov 2, 2026
* fix: retain address context cleanup failures

* fix!: preserve address context input errors

BREAKING CHANGE: Strict clients that cached the previous full inspect_address_context output schema must refresh tools/list and accept the typed error field on unavailable facets.

* test: use session contract for address context
@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant