anthropics / anthropics/claude-agent-sdk-typescript

[Bug] SDK injects undocumented "task tools" harness reminder into system prompt — echoed verbatim by model under long context

Aperta
#404 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Shell
Stelle
1.8k
Fork
226
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## Issue Summary

When using the Claude Agent SDK embedded in a host application, the SDK's internal runtime (claude.exe) injects a harness-level reminder into the system prompt:

> "The task tools haven't been used recently. If you're working on tasks that would benefit from tracking progress, consider using TaskCreate to add new tasks and TaskUpdate to update task status (set to in_progress when starting, completed when done). Also consider cleaning up the task list if it has become stale. Only use these if relevant to the current work. This is just a gentle reminder - ignore if not applicable."

Under long-session context pressure, **the model echoes this reminder verbatim into its own reply text**, leaking internal SDK boilerplate into user-visible conversation output. This happens regardless of the model provider (reproduced on Anthropic native models and third-party models).

## Root cause

1. **The reminder text originates from `claude.exe`**, not from the host application. We verified this by searching the SDK runtime binary (`@anthropic-ai/claude-agent-sdk-win32-x64`, 253 MB): the string `"task tools haven't been used"` is found at internal offset ~132,645,759.

2. **There is no public SDK setting to disable this injection.** `criticalSystemReminder_EXPERIMENTAL` exists in the type definitions (`sdk.d.ts:61-63`) but is a different feature (plan-mode / critical workflow reminder, not the task-tools harness text).

3. The host application (Cherry Studio) passes a custom `systemPrompt` via `ClaudeCodeSettings`, but the harness reminder is appended by the SDK runtime internally with no opt-out mechanism.

## Reproduction

- Host: Cherry Studio (any version with embedded Claude Agent SDK) — but the issue is host-agnostic; any application embedding the SDK runs the same `claude.exe` runtime.
- Model: DeepSeek V4 (Flash / Pro), also reported with Anthropic native models.
- Trigger: Long agent sessions with many turns. The reminder appears in the system prompt every Nth turn; under context pressure the model eventually echoes it into the visible assistant reply.
- Cross-platform: macOS and Windows 11 both confirmed.
- Scale: 150+ occurrences tracked in the host application's issue tracker (CherryHQ/cherry-studio#18175).

## Expected behavior

1. Provide a documented, stable setting to opt out of harness-level system prompt injections (e.g. `ClaudeAgentSettings.disableInternalReminders: boolean`, or a `systemPromptInjections` list the host can control).

2. Alternatively, clearly mark such injected reminders (e.g. via a designated part type or metadata field) so that downstream consumers can identify and suppress them reliably — the current approach of text-pattern matching at the persistence layer is fragile and not a long-term solution.

## Why this matters beyond the host application

Any downstream host embedding the SDK faces the same problem: internal SDK text leaking into user-visible model output with no way to prevent it. The only available countermeasure is downstream regex-based text stripping, which is version-fragile (reminder text changes across SDK releases) and cannot cover future injections. A first-party SDK knob is the right fix.

## Related

- CherryHQ/cherry-studio#18175 — original issue with 150+ user reports across macOS / Windows
- Companion to anthropics/claude-agent-sdk-typescript#8 ("SDK injects unwanted tools and coding context") — same class of problem: the SDK adds content to the system prompt that the host application cannot control or suppress.

Submitted via Cherry Assistant's DeepSeek Agent (V4 Flash).

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.