Sleeptalk

Agent integrations

Claude Code

Talk to Claude Code through the Claude Agent SDK, with tool results, permission callbacks, and task lifecycle events.

Setup

  1. Install Claude Code on the runtime host: npm install -g @anthropic-ai/claude-code. If claude is missing, the setup wizard offers to run this for you.
  2. Install Sleeptalk's claude extra in the same environment as Sleeptalk. It adds claude-agent-sdk.
  3. Log Claude Code in on the runtime host, or provide an Anthropic API key.
  4. Run sleeptalk and choose Claude Code, or let your agent run sleeptalk host ensure --agent claude_code.
In the same Python environment as Sleeptalk
python -m pip install 'sleeptalk[claude]'

The 0.1.0 extra pins Claude Agent SDK 0.2.165. For an installation managed by uv, use uv tool install --reinstall --python 3.11 'sleeptalk[claude]' and include any other extras you use.

The setup probe sends no prompt. With a first-party Anthropic API key, it checks the key against Anthropic's API. With a Claude login, it reports that a login is configured but cannot prove live access; OAuth, custom gateways, Bedrock, Vertex, and Foundry are not verified.

Connection and session

The adapter owns a ClaudeSDKClient with partial messages enabled. It records the upstream session ID and resumes it when reconnecting within the call. It does not hand off from another Claude conversation.

Event mapping

Upstream eventSleeptalk handlingCaller experience
content_block_delta.text_deltaAssistantDelta and sentence streaming.Incremental spoken reply.
tool_use / tool_resultTool start and completed or failed result, correlated by tool-use ID.Narration and result activity.
can_use_tool callbackPermissionRequested in pending or default mode.The SDK waits for a decision.
task_started, task_progress, task_notification, task_updatedWorkerEvent keyed by tool-use ID or task ID.Sub-agent start, progress, and end.
Result message usageUsageReported, including cost when supplied.Usage data, not spoken text.

Permissions and sub-agents

permission_modeClaude SDK modeTool behavior
skip (used when the field is empty), bypassbypassPermissionsTools run without asking.
pending, defaultdefault, with the SDK permission callbackThe caller decides each tool call.
deny, dontAskdontAskTools that would ask are refused.
acceptEdits, plan, autoThe SDK mode of the same nameAs Claude Code defines it.

A profile without permission_mode bypasses permissions. Set pending if you want to approve tools by voice. Setup probes require pending or default.

Agent and legacy Task delegation tools produce correlated worker events. TaskCreate is a task-list tool, not a sign that a worker started.

Voice and interruption

Assistant text passes through the shared sentence streamer before speech. Tool activity follows your narration setting; a tool result is not read aloud in full.

Barge-in calls the SDK interrupt with a bounded wait and keeps the session ID for reconnect. Pending permission requests are denied during an abort. The Cancel control interrupts the session; it does not stop a named background worker on its own.

Limits and troubleshooting

  • "Install the Claude SDK extra in the selected Sleeptalk runtime." Install sleeptalk[claude] in the same environment as the sleeptalk you run.
  • "Complete Claude login privately on the runtime host." Log Claude Code in on the machine that runs Sleeptalk.
  • A reply stalls after an interruption. Check the call log for session reconnect errors.

Implementation: SDK adapter, worker mapping.