Use this guide when your own Claude Agent SDK application should run inside Nullspace as a repeatable Function. If you want the Claude Code CLI inside a machine workspace, use Claude Code instead. Claude Agent SDK apps usually fit mode = "job": receive input, run the agent, write output files, and exit. Use a service only when your app exposes an HTTP API around Claude.

Deploy As A Job

function.py
import nullspace

function = nullspace.Function(
    "claude-agent-sdk-job",
    mode="job",
    template="base",
    workdir="/workspace/project",
    install="python -m pip install -e .",
    entrypoint="python main.py",
    env=nullspace.Env(required=["ANTHROPIC_API_KEY"]),
    outputs=nullspace.Outputs(paths=["result.json", "reports"]),
)
Deploy and run:
nullspace functions deploy
nullspace functions run claude-agent-sdk-job \
  --input-json '{"prompt":"write a short release note"}' \
  --env ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY" \
  --retain-on-failure \
  --json

nullspace functions logs claude-agent-sdk-job --run fnrun_123
nullspace functions outputs claude-agent-sdk-job --run fnrun_123
nullspace functions machine claude-agent-sdk-job --run fnrun_123
See the Claude Agent SDK job example for a complete project.

Debugging

Every run has a backing machine. Use --retain-on-failure when a failed Claude run should leave a retained machine for PTY, SSH, command, file, or desktop inspection.
nullspace functions shell claude-agent-sdk-job \
  --run fnrun_123 \
  --cmd "ls -la && find reports -maxdepth 2 -type f"

State Boundary

Nullspace owns Function runs, logs, outputs, and backing machines. Claude Agent SDK conversation state remains owned by your app. Keep session files in a volume or app-managed storage when they must survive machine cleanup, and pass your own conversation ID through the job input instead of treating a Nullspace run ID as a Claude session ID.