ag-ui-protocol / ag-ui-protocol/ag-ui
[Bug]: @ag-ui/claude-agent-sdk: buildOptions flattens a preset-object systemPrompt to "[object Object]"
- Langage dominant
- Python
- Étoiles
- 15.9k
- Forks
- 1.4k
- Merge moyen
- 1 j 17 h
- PR mergées (30 j)
- 163
Description
### Pre-flight Checklist
- [x] I have searched existing issues and this hasn't been reported yet.
- [x] I am using the **latest** version of AG-UI.
### Describe the Bug
`buildOptions` in `@ag-ui/claude-agent-sdk` appends the ag-ui state/context
addendum to `Options.systemPrompt` by casting it `as string` and interpolating
it into a template literal:
```ts
const base = (merged.systemPrompt as string) ?? "";
merged.systemPrompt = base ? `${base}\n\n${addendum}` : addendum;
```
`Options.systemPrompt` also accepts the SDK's preset-object form
(`{ type: 'preset', preset: 'claude_code', append }`). Interpolating that object
into the template literal yields the literal string `"[object Object]"`,
destroying both the preset and the caller's entire `append` text. The agent then
runs with a corrupted system prompt.
### Steps to Reproduce
1. Configure `ClaudeAgentAdapter` with a `systemPrompt` in the SDK preset-object
form: `{ type: 'preset', preset: 'claude_code', append: '…' }`.
2. Send a run that carries ag-ui `context` or `state`, so
`buildStateContextAddendum` produces a non-empty addendum (the common case for
any CopilotKit integration using `useCoAgent`).
3. Inspect the `Options.systemPrompt` passed to the SDK `query()`.
### Expected Behavior
The preset object is preserved and the addendum is folded into its `append`
field, so `type`, `preset`, and the caller's `append` all survive. Instead,
`systemPrompt` becomes the literal string `"[object Object]"`.
### Environment
```text
AG-UI package(s): @ag-ui/claude-agent-sdk (reproduced on main / 0.0.3, also 0.0.2)
Runtime: Node.js
```
### Additional Context
Proposed fix: branch on the declared `Options.systemPrompt` shapes before
appending — object (preset) → spread and fold the addendum into `append`; string
(or nullish) → existing concatenation. A PR is opened alongside this issue.
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.