Skip to content

Accept raw control characters inside JSON strings in model replies - #255

Merged
tzhouam merged 1 commit into
mainfrom
kb/json-control-chars
Sep 30, 2026
Merged

tzhouam merged 1 commit into
mainfrom
kb/json-control-chars

Conversation

@tzhouam

@tzhouam tzhouam commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

The first kb init pilot (afd-plugin skeleton, dry run) stopped on its first generator call: the model returned a well-formed fenced JSON object whose architecture_md value held an ASCII diagram with literal newlines. Strict json.loads rejects raw control characters inside strings, so kb_service.models.parse_json_object raised ModelUnavailable and the stage blocked ($0.78 call wasted).

parse_json_object now parses with strict=False: control characters inside strings are data, not structure. Anything else malformed (unterminated strings, non-objects, no JSON) is still refused. This parser is shared by the knowledge service (intake, gate, judge), which benefits the same way.

Tests

  • test_kb_intake_gate.py::test_parse_json_object_accepts_raw_newlines_inside_strings (fenced + bare, newline/tab in strings; unterminated still refused).
  • Full local CI mirror green (pytest, doc links/citations, SPEC freshness --strict, knowledge linters); commit gate approved.

Independent of the kb init stack (based on main); found by the kb init pilot.

🤖 Generated with Claude Code

The first kb init pilot (afd-plugin skeleton, dry run) stopped on its
first generator call: the model returned a well-formed fenced JSON
object whose architecture_md value held an ASCII diagram with literal
newlines, and strict json.loads rejects raw control characters inside
strings, so parse_json_object raised ModelUnavailable ($0.78 wasted).
Parse with strict=False: control characters in strings are data, not
structure; anything else malformed is still refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 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-09-30T12:44:49.239059Z 0e66455 PR opened
ℹ️ 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.

@tzhouam
tzhouam merged commit 27fdaf3 into main Sep 30, 2026
2 checks passed
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