Agent integrations
Claude Code
Talk to Claude Code through the Claude Agent SDK, with tool results, permission callbacks, and task lifecycle events.
Setup
- Install Claude Code on the runtime host:
npm install -g @anthropic-ai/claude-code. Ifclaudeis missing, the setup wizard offers to run this for you. - Install Sleeptalk's
claudeextra in the same environment as Sleeptalk. It addsclaude-agent-sdk. - Log Claude Code in on the runtime host, or provide an Anthropic API key.
- Run
sleeptalkand choose Claude Code, or let your agent runsleeptalk host ensure --agent claude_code.
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 event | Sleeptalk handling | Caller experience |
|---|---|---|
content_block_delta.text_delta | AssistantDelta and sentence streaming. | Incremental spoken reply. |
tool_use / tool_result | Tool start and completed or failed result, correlated by tool-use ID. | Narration and result activity. |
can_use_tool callback | PermissionRequested in pending or default mode. | The SDK waits for a decision. |
task_started, task_progress, task_notification, task_updated | WorkerEvent keyed by tool-use ID or task ID. | Sub-agent start, progress, and end. |
| Result message usage | UsageReported, including cost when supplied. | Usage data, not spoken text. |
Permissions and sub-agents
permission_mode | Claude SDK mode | Tool behavior |
|---|---|---|
skip (used when the field is empty), bypass | bypassPermissions | Tools run without asking. |
pending, default | default, with the SDK permission callback | The caller decides each tool call. |
deny, dontAsk | dontAsk | Tools that would ask are refused. |
acceptEdits, plan, auto | The SDK mode of the same name | As 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 thesleeptalkyou 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.