Skip to content

Watch agent-sdk for bridge onApplyFlagSettings callback (effort changes) #19

Description

@yyq1025

Context

Verified via spike (2026-05-30, agent-sdk 0.3.158) that claude.ai's web UI sends effort changes to BYOC bridge workers as apply_flag_settings control_requests, with payload:

{
  "subtype": "apply_flag_settings",
  "settings": { "effortLevel": "low" | "medium" | "high" | "max" }
}

The bridge SDK's internal handleServerControlRequest (in src/bridge/bridgeMessaging.ts) currently only dispatches 5 subtypes:

  • initialize / set_model / set_max_thinking_tokens / set_permission_mode / interrupt

apply_flag_settings falls through to the default branch → SDK auto-replies with error: "unknown subtype". No inbound callback firesAttachBridgeSessionOptions exposes onSetModel / onSetMaxThinkingTokens / onSetPermissionMode but no onApplyFlagSettings.

Empirical proof

Same spike also caught these subtypes claude.ai sends but the bridge SDK doesn't expose:

  • apply_flag_settings (effort changes, 8 fires across two model variants)
  • get_context_usage (web polls context usage, 6 fires)
  • set_model extended payload format: "claude-opus-4-7[1m]" (1M context window suffix encoded into model string — already passes through via existing onSetModel, but new syntax)

apply_flag_settings is the highest-value gap — effort is now a real product feature on Opus 4.7+ / Sonnet 4.6+ and sidecode silently no-ops when the user changes it via the web UI.

What sidecode does for now

Nothing. Documented as a known limitation: effort changes on claude.ai do NOT propagate to sidecode bridged sessions; the worker uses its spawn-time default. Revisit on every agent-sdk minor bump.

Acceptance / close conditions

Check node_modules/@anthropic-ai/claude-agent-sdk/bridge.d.ts after each agent-sdk upgrade:

  • AttachBridgeSessionOptions gains onApplyFlagSettings?: (settings: Partial<Settings>) => Promise<void> | void (or equivalent)
  • OR a more general onSetSettings / per-key callback (onSetEffort?) lands

When either ships → wire it in packages/daemon/src/bridge/bridge-transport.ts BridgeInboundHandlers → route through BridgeService.onSetEffortruntime.query?.applyFlagSettings({effortLevel}). Same pattern as the existing onSetModel wiring.

Notes

  • Spike script lived at spikes/effort-probe.mjs (deleted post-verify, gitignored).
  • Verified against current sidecode bridge stack (M2 read-in landed): cse_ session, attach bidirectional, all 7 SDK callbacks wired with logging, 8 effort changes from claude.ai → 0 callback fires → event-log readback revealed the apply_flag_settings subtype.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions