Skip to content

fix(core): refuse a compaction reply that calls a tool - #49

Merged
TaewoooPark merged 3 commits into
mainfrom
fix/compaction-tool-call
Nov 2, 2026
Merged

TaewoooPark merged 3 commits into
mainfrom
fix/compaction-tool-call

Conversation

@TaewoooPark

@TaewoooPark TaewoooPark commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Problem

A compaction request can receive a short working preamble followed by a tool call. Previously, the call was ignored and the remaining preamble could replace the transcript as if it were a handoff summary, losing the accumulated working context.

Change

  • Reject summaries containing parsed tool calls or inline calls, including malformed and truncated calls. Preserve the full transcript on failure; never execute a tool from a summary response.
  • Allow a summary to quote the literal <tool_call> token in inline code or a source string. Preserve the original summary text. This narrow exception does not allow quoted or fenced call payloads.
  • Give native-call regression fixtures realistic reasoning boundaries, and assert complete transcript preservation and that rejected calls never execute.
  • Bump the root package, CLI package and CLI version to 0.4.4.

Retry scheduling is unchanged: automatic compaction is re-armed when a later successful working response reports prompt usage above the threshold. This change does not introduce an unconditional retry loop or guarantee recovery from a context-window HTTP error.

Maintainer validation

Tested on macOS 26.6.2 arm64 in isolated checkouts, with localhost fixtures and dummy credentials:

  • pnpm install --frozen-lockfile, pnpm typecheck, pnpm build, pnpm test (1,691 passed) and pnpm lint:tools passed.
  • Compaction tests: 23 passed. Five quoted-marker cases failed on the original PR head and pass after the follow-up fix. Against the v0.4.3 base, nine cases fail, including the realistic native-call case.
  • Built CLI exercised through a real macOS PTY and a visible xterm.js 6.0.0 terminal at 120×32, using Node 24.13.0. Base/head comparison reproduces preamble-only context replacement on base and verifies full-history preservation on the patched head; a later valid summary compacts successfully. Literal-marker summaries remain intact.
  • Four visible CLI runs / 14 localhost HTTP requests; summary tool calls never executed. Actual hosted-model behavior was not sampled.

PR and merged-main CI both passed (all five jobs). Merged as 310b0c398dfb67ed7d97ce3a95a5b9863bdaa360. No existing GitHub issue is linked to this PR.

Release

Released as 0.4.4 and verified on npm, including the latest tag. A fresh isolated install passed motif version, motifcode version and a local HTTP smoke test. The published CLI bundle matches the verified Mac build byte-for-byte, and public provenance metadata identifies the merged commit and release workflow.

The summary request tells the model not to call a tool. A model that keeps
working instead answers with one line of intent and a call, such as "Let me
check the current state first." With the call stripped, that line was not
empty, so it became the summary and replaced the whole transcript: the next
turn started with the task and one sentence.

A reply that calls a tool, as a parsed tool call or as an inline <tool_call>
block, is now a failed compaction. The loop already handles that case: it
keeps the full transcript, warns, and compacts again once the next request
crosses the limit.
@TaewoooPark

Copy link
Copy Markdown
Owner Author

Thanks for the focused compaction fix and regression tests. I reviewed and tested 5fc07ae5d368aa84ee8b9a9c12053a8b6d74147c on this Apple Silicon Mac.

The original fix correctly prevents a tool-calling summary from replacing the conversation. The review also reproduced a compatibility regression: summaries quoting the literal <tool_call> marker were rejected. Commit 35e2f8c adds a narrow exception for the quoted marker itself, while continuing to reject actual, fenced, malformed, and unfinished calls. It also strengthens the native-tool and history-preservation regressions. Commit 5fc07ae prepares version 0.4.4.

Validation: all 1,691 tests across 97 files, typecheck, build, and tool lint passed locally. The 23 compaction tests include cases that fail on the original PR and on the base where appropriate. The built CLI was also exercised in a visible PTY terminal on macOS with a local HTTP fixture: rejected native calls preserve the complete conversation, subsequent valid compaction succeeds, and literal-marker summaries remain unchanged. These are deterministic fixture checks, not live-model testing.

All five current-head CI jobs passed: https://github.com/TaewoooPark/Motifcode/actions/runs/41366451151

No remaining blocking regression or unrelated scope expansion found. Merging as a squash commit, then verifying main and the 0.4.4 release. This PR has no linked closing issue; the broader roadmap remains open.

@TaewoooPark
TaewoooPark merged commit 310b0c3 into main Nov 2, 2026
5 checks passed
@TaewoooPark

Copy link
Copy Markdown
Owner Author

Released and verified as 0.4.4.

No closing issue or exactly linked contribution card was found, so no unrelated issue/card was closed. Automatic retry scheduling remains unchanged, as documented in the release notes. Thanks for the contribution!

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