Claude Seekho

Advanced API Features

These features are for production agents and long conversations: computer use, memory, code execution, compaction, context editing, fallbacks and more. Many of them are beta — beta features need client.beta.messages and the betas=[...] header.

11.1 Computer use

Claude can look at screenshots and drive the mouse and keyboard, the way a person uses a computer. This is client-side: you take screenshots in a VM/container and execute the actions.

Computer use loop
  1. 1.Send screenshot: image of the screen
  2. 2.Claude: left_click, type, zoom ... (tool_use)
  3. 3.Your harness: run the action in the VM
  4. 4.tool_result: new screenshot / OK

The loop repeats until the task is done

r = client.messages.create(
    model="claude-opus-5-5", max_tokens=16000,
    tools=[{"type": "computer_toolset_20260801"}],     # new toolset: no name/dimensions
    messages=[{"role": "user", "content": "Open the browser and check flight prices"}],
)
# Names of Claude's tool_use blocks: screenshot, left_click, type, zoom ... (17 members)
# Echo "toolset_name": "computer" in every tool_result
  • The new computer_toolset_20260801 (GA on the Claude API and Google Cloud). Opus 5.5 accepts only the toolset; the older computer_20251124 works on some platforms (Bedrock).
  • Always run it in an isolated VM/container, away from sensitive accounts, with human confirmation on risky actions.
  • Claude in Chrome and Claude's browser/desktop agents are based on this same capability.

11.2 Memory tool

The memory tool lets Claude remember information across conversations — by creating files in a /memories directory. It is a client-side tool: you implement the storage (disk, DB, S3).

PointDetail
Type{"type": "memory_20250818", "name": "memory"}
Commandsview, create, str_replace, insert, delete, rename
HelpersHelper classes for the memory backend in the Python/TypeScript/Java SDKs
SecurityNever put secrets/passwords in memory; in multi-user apps use a per-user directory + auth; mind GDPR for PII
With context editingBefore old tool results are cleared, Claude writes the important information to memory

11.3 Code execution, files and programmatic tool calling

  • Code execution tool (code_execution_20260521): Python/bash in Anthropic's sandbox container. Data analysis, charts, file conversion. The sandbox already has python-docx, python-pptx, matplotlib, pillow, pypdf.
  • Files Claude creates (DOCX, XLSX, PDF, PNG) are downloaded through the Files API.
  • Programmatic tool calling (code_execution_20260120 + allowed_callers on the tool): Claude calls your tools in a loop from inside code — one script instead of 100 round trips for 100 rows. It saves both tokens and latency.
  • Agent Skills via API: container={"skills": [...]} + the code execution tool — for example making files with the built-in pptx, xlsx, docx, pdf skills. Custom skills are uploaded through the Skills API (client.skills).

11.4 Tool search and Advisor tool

FeatureWhat it doesWhen
Tool search (regex / BM25)defer_loading: true on tools; Claude searches and loads them when neededDozens/hundreds of tools (big MCP servers) — saves context. You cannot defer all tools
Advisor toolA small/fast executor model takes advice from a more capable model (e.g. Sonnet executor → Opus advisor)Lower cost, high quality. The advisor must be as capable as the executor or more

11.5 Compaction (long conversations)

When the conversation nears the context window, the server summarizes the older part into a compaction block. The conversation never ends.

messages = []
def chat(user_message):
    messages.append({"role": "user", "content": user_message})
    r = client.beta.messages.create(
        betas=["compact-2026-01-12"],
        model="claude-opus-5-5", max_tokens=16000,
        messages=messages,
        context_management={"edits": [{"type": "compact_20260112"}]},
    )
    messages.append({"role": "assistant", "content": r.content})  # the FULL content — the compaction block is required
    return next(b.text for b in r.content if b.type == "text")

11.6 Context editing

Compaction summarizes; context editing clears old things — such as old tool results or thinking blocks. Useful in agent loops where earlier file reads are no longer needed.

r = client.beta.messages.create(
    model="claude-opus-5-5", max_tokens=4096,
    betas=["context-management-2025-06-27"],
    context_management={"edits": [
        {"type": "clear_tool_uses_20250919"},      # remove old tool results
        # {"type": "clear_thinking_20251015"},     # remove old thinking blocks
    ]},
    tools=tools, messages=messages,
)

11.7 Mid-conversation system messages

If you need to give an operator instruction mid-conversation (mode switch, injected state), do not edit the top-level system (the cache will break). Instead add {"role": "system"} to messages — the cached prefix survives, and this is a prompt-injection-safe operator channel.

r = client.messages.create(
    model="claude-opus-5-5", max_tokens=16000,
    system=[{"type": "text", "text": STABLE_SYSTEM, "cache_control": {"type": "ephemeral"}}],
    messages=history + [
        {"role": "user", "content": user_message},
        {"role": "system", "content": "Terse mode on — answer in under 40 words."},
    ],
)   # must come after a user message; cannot be messages[0]

11.8 Preserved thinking

  • Thinking blocks of the new models (Fable 5.1, Opus 5.5, Sonnet 5.5) are tied to the model and the conversation.
  • If you edit earlier history (change or remove messages in the middle), old thinking blocks can become invalid — on new accounts even a 400.
  • Rule: keep the harness append-only. Send thinking blocks back unchanged; the API itself drops (unbilled) the ones the model cannot read.

11.9 Refusals and server-side fallbacks

If the safety classifier declines a request, you get HTTP 200 with stop_reason: "refusal". If you opt in to fallbacks, the API retries on another model within the same call.

r = client.beta.messages.create(
    model="claude-opus-5-5", max_tokens=16000,
    betas=["server-side-fallback-2026-07-01"],
    fallbacks="default",            # routes by itself based on the refusal category
    messages=[{"role": "user", "content": "..."}],
)
if r.stop_reason == "refusal":      # the whole chain declined
    print(r.stop_details.category)  # e.g. "cyber", "bio"

11.10 Smaller but important features

FeatureDetail
Eager input streamingeager_input_streaming: true on a tool with streaming + client tools — big tool inputs (file content) arrive in chunks. Validate before parsing
Task budgets (beta)output_config.task_budget — the agent loop sees a token budget and paces itself (min 20,000)
Per-message effort (beta)Change effort mid-conversation without breaking the cache
Fast mode (preview)speed: "fast" — ~2.5x faster output on Opus, premium price, Claude API only
Priority TierGuaranteed capacity commitment (on some models); not on the new 5.x models
inference_geoWhich region (e.g. us) inference runs in — data residency
Cache diagnostics (beta)Server-side diagnosis of why a cache miss happened
Models APILive check of max_input_tokens, max_tokens, capabilities
Search results blockProvide your own RAG results with citations