Skip to content

fix(server): Claude memory runs return structured output again - #173

Merged
ScriptedAlchemy merged 1 commit into
ScriptedAlchemy:mainfrom
HashemKhalifa:fix/claude-memory-structured-output
Nov 20, 2026
Merged

ScriptedAlchemy merged 1 commit into
ScriptedAlchemy:mainfrom
HashemKhalifa:fix/claude-memory-structured-output

Conversation

@HashemKhalifa

@HashemKhalifa HashemKhalifa commented Nov 20, 2026 •

Copy link
Copy Markdown

Problem

Every isolated Claude text-generation run fails: memory extraction (generateKnowledgeCandidates), checkFactStanding, curateProjectMemory, generateConversationSummary and generateModelEvaluation. The CLI exits 0, but its JSON reply has no structured_output key, so the result is discarded and nothing is saved to project memory. Thread titles keep working because they are not isolated.

The cause is --disallowedTools '*' in the isolated argument list (ClaudeTextGeneration.ts:337). With Claude CLI 2.1.329 that flag also blocks the internal tool the CLI uses to return --json-schema output, so the model replies in plain text. Repro with the same schema, --tools "" and --setting-sources "" on every run:

Extra flags Exit structured_output
--safe-mode --disallowedTools '*' (current isolated args) 0 missing
--safe-mode 0 {"ok":true}
--disallowedTools '*' 0 missing
S='{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"],"additionalProperties":false}'
echo 'Return ok=true.' | claude -p --output-format json --json-schema "$S" --tools "" --safe-mode --disallowedTools '*' --setting-sources "" | grep -o '"structured_output":[^}]*}' || echo MISSING

Change

Drop --disallowedTools * from the isolated arguments. It isolated nothing: isolated runs never investigate, so they already pass --tools "" (line 333), which removes every tool. --safe-mode, --setting-sources "", the temporary working directory and --strict-mcp-config are unchanged.

The three isolated tests asserted the broken flag. They now require --safe-mode --setting-sources and forbid both --bare and --disallowedTools. To allow that, the fake CLI fixture reads T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN as one forbidden fragment per line. The fixture's existing check that --tools is "" still holds for these runs.

Scope

Bug fix for an obvious regression with the repro above; no separate issue.

Verification

  • RED: with only the test changes, vp test run src/textGeneration/ClaudeTextGeneration.test.ts fails the 3 isolated tests (args missing expected content). GREEN after the fix: vp test run src/textGeneration/ passes 153/153 in 9 files. vp check is clean on the 3 changed files.
  • Real CLI: the table above, run against Claude CLI 2.1.329 on macOS.
  • Live app: on a running T3 desktop build of main, I set the Claude binary path to a wrapper that only removes --disallowedTools * when --json-schema is present. From the server trace (ClaudeTextGeneration.* spans, 2026-11-20 UTC): before the change, 14 curateProjectMemory and 52 generateConversationSummary runs, all Failure. In the first ten minutes after, 6 curateProjectMemory, 54 generateConversationSummary, 3 generateKnowledgeCandidates and 1 checkFactStanding, all Success.
  • Not checked: Claude CLI versions other than 2.1.329, and Windows.

Isolated text generation (memory extraction, fact checks, memory curation,
conversation summaries, model evaluations) passed `--disallowedTools *`.
Claude CLI 2.1.329 then exits 0 without a `structured_output` key, so
every isolated run failed. `--tools ""` already removes every tool, so
the flag added no isolation. Drop it and assert it stays out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 777d6a3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T14:07:28.734434Z 777d6a3 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.

@ScriptedAlchemy ScriptedAlchemy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed the isolated Claude invocation and fixture changes. The invocation retains safe mode, an empty built-in tool list, and disabled setting sources. The fixture covers removal of the wildcard denial that blocked structured output.

@ScriptedAlchemy
ScriptedAlchemy merged commit e0175c6 into ScriptedAlchemy:main Nov 20, 2026
18 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.

2 participants