Skip to content

fix(claude): accept initialize capabilities sent as a list of names - #25

Merged
sbis04 merged 1 commit into
mainfrom
ayush/claude-initialize-capabilities-list
Oct 2, 2026
Merged

sbis04 merged 1 commit into
mainfrom
ayush/claude-initialize-capabilities-list

Conversation

@ayushflow

Copy link
Copy Markdown
Contributor

Summary

Claude Code 2.1.287 answers the initialize control request with "capabilities": ["ui_surface_v1"], a list of names. ClaudeInitializationResult.fromJson requires an object here, so asJsonMap throws FormatException: initialize.capabilities must be a JSON object. That fails the whole initialize response, and every Claude session against that CLI dies before its first turn.

The FlutterFlow desktop agent panel always runs Claude over ACP through dart_acp_claude. On 2.1.287 every Claude chat fails on the first message with:

JsonRpcRequestException(-32603, Internal error, {details: FormatException: initialize.capabilities must be a JSON object})

Change (packages/claude_agent_sdk/lib/src/initialization.dart)

  • A list of names reads as {name: true}. ui_surface_v1 becomes {'ui_surface_v1': true}.
  • An object is kept exactly as before.
  • Any other shape (or none) gives an empty map instead of an exception. The original value stays in raw. capabilities is an open-set advertisement, so a shape this SDK doesn't know shouldn't end the session.
  • The public type (JsonMap capabilities) is unchanged.

The init system message already decodes capabilities as a string list (message_codec.dart), so this matches what the CLI sends there too.

Verified

  • The response shape was checked against the real CLI. I sent {"type":"control_request","request_id":"r1","request":{"subtype":"initialize","hooks":null}} to claude -p --input-format stream-json --output-format stream-json (2.1.287), and the response has capabilities: ["ui_surface_v1"].
  • New tests in test/models_test.dart cover a list, an object, and a missing or unknown shape. Without the fix, the list test fails with the exact error above; with it, all 104 claude_agent_sdk tests pass.
  • dart analyze --fatal-infos packages/claude_agent_sdk and dart format are clean.

Follow-up in FlutterFlow: bump the claude_agent_sdk override in flutterflow/pubspec.yaml (currently 45023fd) to the merged commit. claude_agent_sdk is identical between 45023fd and main, so the bump carries only this fix.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PxGo16ehbCKTyimWWkrjEt

Claude Code 2.1.287 answers the initialize control request with
`"capabilities": ["ui_surface_v1"]`, a list of names, where this SDK
required an object. asJsonMap threw "initialize.capabilities must be a
JSON object", which failed the whole initialize response, so every
session against that CLI died before its first turn.

A listed name now reads as `name: true`; an object is kept as before;
any other shape is left to `raw` instead of failing. The field is an
open-set advertisement, so an unknown shape must not end the session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PxGo16ehbCKTyimWWkrjEt
@sbis04
sbis04 merged commit d01027b into FlutterFlow:main Oct 2, 2026
0 of 2 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