Skip to content

fix: repair truncated JSON, reduce summon/MOIM log noise#8280

Closed
eugenio wants to merge 2 commits intoblock:mainfrom
eugenio:fix/bug-fixes-8272-8273-8274
Closed

fix: repair truncated JSON, reduce summon/MOIM log noise#8280
eugenio wants to merge 2 commits intoblock:mainfrom
eugenio:fix/bug-fixes-8272-8273-8274

Conversation

@eugenio
Copy link
Copy Markdown

@eugenio eugenio commented Apr 3, 2026

Summary

Three targeted fixes for log noise and tool call reliability when using non-Anthropic models via OpenAI-compatible proxies:

Test plan

  • test_safely_parse_json updated — truncated JSON now repaired instead of erroring
  • test_repair_truncated_json added — covers unclosed strings, nested objects, arrays, large payloads
  • All 57 related unit tests pass (providers::utils, conversation, agents::moim)
  • Manual: verify WARN-level summon/MOIM messages no longer appear in CLI logs

🤖 Generated with Claude Code

- Add `repair_truncated_json()` fallback to `safely_parse_json()` that
  closes unclosed strings and brackets in truncated tool call arguments.
  Fixes large-payload EOF errors (col 27409+) from streaming models. (block#8272)

- Downgrade summon frontmatter parse warning from WARN to DEBUG and
  include the source file path for easier debugging. Files without a
  `name` field are expected (non-extension markdown) and should not
  pollute logs. (block#8273)

- Add "Merged text content", "Removed trailing assistant message", and
  "Trimmed trailing whitespace from assistant message" to the MOIM
  expected-issues list so they no longer trigger WARN-level log entries
  on every LLM call. (block#8274)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5f4680f67

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +536 to +539
// Close an unclosed string
if in_string {
repaired.push('"');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle dangling escape when repairing truncated JSON

When truncation happens immediately after a backslash inside a JSON string, escape_next is left true at end-of-input, but the repair logic still appends only " and closers. That produces invalid JSON like {"k":"abc\"} (the appended quote is escaped), so safely_parse_json still fails for a common truncation boundary in streamed tool arguments (e.g., paths or escaped content). The repair path should account for a dangling escape before closing the string.

Useful? React with 👍 / 👎.

When truncation occurs immediately after a backslash inside a JSON
string, the appended closing quote would be escaped, producing invalid
JSON like {"k":"abc\"}. Drop the trailing backslash before closing
the string.

Addresses Codex review feedback on block#8280.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@eugenio
Copy link
Copy Markdown
Author

eugenio commented Apr 4, 2026

Superseded by #8310 which includes the truncated JSON repair and all other fixes from this PR.

@eugenio eugenio closed this Apr 4, 2026
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