#2037·stagehand

core(cua): implement addContextNote parity for Google/Anthropic/Microsoft clients

Author: BABTUNACreated Apr 24, 2026Updated Sep 24, 2026

Why

V3CuaAgentHandler injects runtime guidance via agentClient.addContextNote(...) for captcha-related flows, but only OpenAICUAClient currently consumes those notes.

As a result, non-OpenAI CUA providers can silently drop important runtime guidance (for example, “captcha already solved; do not click again”), which can cause repeated captcha interaction and less reliable task continuation.

Related merged work:

  • #2023
  • #1954

Current behavior

  • addContextNote(...) is called in packages/core/lib/v3/handlers/v3CuaAgentHandler.ts (captcha solved/errored + click-guard paths)
  • AgentClient.addContextNote(...) defaults to no-op
  • OpenAICUAClient overrides and injects notes into the next model turn
  • GoogleCUAClient, AnthropicCUAClient, and MicrosoftCUAClient do not currently consume these notes

Proposed enhancement

Implement parity note handling in non-OpenAI CUA clients:

  1. Add pending context-note queue behavior in:
    • GoogleCUAClient
    • AnthropicCUAClient
    • MicrosoftCUAClient
  2. Inject queued notes into the next model turn in provider-appropriate message/input format
  3. Clear queued notes after successful injection (same one-shot semantics as OpenAI)

Suggested files

  • packages/core/lib/v3/handlers/v3CuaAgentHandler.ts
  • packages/core/lib/v3/agent/AgentClient.ts
  • packages/core/lib/v3/agent/OpenAICUAClient.ts
  • packages/core/lib/v3/agent/GoogleCUAClient.ts
  • packages/core/lib/v3/agent/AnthropicCUAClient.ts
  • packages/core/lib/v3/agent/MicrosoftCUAClient.ts

Acceptance criteria

  • Context notes injected by V3CuaAgentHandler are consumed by Google/Anthropic/Microsoft CUA clients
  • Notes appear in the next turn only (then are cleared)
  • Existing OpenAI behavior remains unchanged
  • Unit tests verify note enqueue/drain behavior per client (or shared helper coverage)

Notes

This is primarily a parity/reliability fix; no API surface changes required.