Skip to content

fix(claude-agent-sdk): preserve preset systemPrompt when appending state/context - #2636

Open
boyuan-fh wants to merge 1 commit into
ag-ui-protocol:mainfrom
boyuan-fh:fh-10254/pr1-systemprompt
Open

fix(claude-agent-sdk): preserve preset systemPrompt when appending state/context#2636
boyuan-fh wants to merge 1 commit into
ag-ui-protocol:mainfrom
boyuan-fh:fh-10254/pr1-systemprompt

Conversation

@boyuan-fh

Copy link
Copy Markdown

Fixes #2630

Summary

buildOptions appended ag-ui state/context to systemPrompt by casting it
as string and interpolating it, which destroyed the SDK's preset-object form
("[object Object]").

Replace the single-path interpolation with a two-way branch:

  • object (preset form): spread the original and fold the addendum into
    the append field so type and preset survive.
  • string / nullish: existing concatenation (no behavior change).

Test plan

  • New src/adapter.buildOptions.test.ts with 6 cases:
    • Preset object with existing append -- both original append and addendum present
    • Preset object with no append -- addendum becomes append
    • Preset object never produces [object Object]
    • Plain string concatenation unchanged
    • Undefined systemPrompt uses addendum alone
    • No addendum leaves systemPrompt unchanged

…ate/context

buildOptions cast Options.systemPrompt as string and interpolated it when appending the ag-ui state/context addendum, so the SDK preset-object form ({ type: 'preset', preset, append }) flattened to "[object Object]", discarding the preset and the caller's append text. Branch on the shape: fold the addendum into a preset object's append; concatenate for the string/nullish form.

Fixes #<issue>
@boyuan-fh
boyuan-fh requested a review from a team as a code owner September 4, 2026 10:24
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.

[Bug]: @ag-ui/claude-agent-sdk: buildOptions flattens a preset-object systemPrompt to "[object Object]"

1 participant