What you get
agent_config() gives each Claude Agent SDK run its prompt and skills. You open a run, pass your own ClaudeAgentOptions to run.query(), and read its message stream as usual. It runs before you have a DecimalAI account. Nothing is patched, so ordinary query() calls elsewhere in your process are left alone.
This page is for claude-agent-sdk, which runs a tool-use loop on the Claude Code engine. For your own Messages API loop, see Anthropic API. For the Claude Code terminal tool, see Claude Code.
Install
claude-agent-sdk.
Run with no account
Save this asmain.py:
DECIMAL_API_KEY, it says so once on stderr and sends nothing to DecimalAI. The project has no skills yet, so the model guesses the command.
async with support.run(question) as run:opens one independent query. Its system text is yourfallback=(later, the saved prompt), then the skill list and one sentence telling the model to load a skill before using it.run.query(options=options)callsquery()with your options plus three things: that system text assystem_prompt, an in-process MCP server nameddecimalai, and permission for its one tool,mcp__decimalai__load_skill, when the run lists skills. The model calls the tool with a skill’s name and gets the skill’s full text back. Your model, tools, other MCP servers, working directory and limits stay as you set them, and your options object isn’t changed.async forneeds anasync def. At module level it is aSyntaxError. Inside an event loop you already have, such as a notebook or a FastAPI handler,await main()instead ofasyncio.run(main()).- No
decimalai.init().init()raises without a key, so a file that calls it can’t run keyless. With a key,agent_config()sets the SDK up fromDECIMAL_API_KEYby itself.
Your own tools
Name Claude Code’s own tools intools=, and add your own through an MCP server of your own:
Add a registry skill
main.py again. The model loads the skill and gives the real command, playwright-cli attach --cdp=http://localhost:9222.
The command wrote the skill’s files to .agents/skills/, listed it in .decimal/skills.toml, and recorded its exact bytes in .decimal/skills.lock. To find others, see Browse the registry. A skill you wrote goes in the same folder, and decimalai skills add <folder-name> lists it.
Add a key
main.py again. The code stays the same.
- The first run connects the project. The agent is created in your workspace. In a git repository, your project’s skill list is copied onto it once, and
.decimal/link.tomlrecords this: commit it. - From now on its skills live on DecimalAI. Each run’s list is picked from them.
- Every query is one trace, filed under
support.name. See Tracing. - Your
fallback=keeps running until you save a prompt.
Change the prompt without redeploying
Write a prompt on the agent’s Prompt & skills page and save it.agent_config() keeps a local copy of the prompt and re-reads it in the background at most once a minute, so the next run gets the saved prompt within a minute, in place of fallback=. An open conversation keeps its first message’s prompt. support.prompt_source and support.prompt_version say which prompt it has read.
With a key, fallback= is what runs when the agent has no saved prompt or DecimalAI can’t be reached at startup. With a key and no fallback=, an unreachable DecimalAI raises rather than start an agent with no prompt.
A saved prompt can hold variables, written {{name}}. Pass their values as variables= to support.run(), as dict keys or attributes, so {{customer.name}} reads variables["customer"]["name"] or variables.customer.name:
{{name}} in your fallback= is filled the same way. A variable with no value raises decimalai.MissingPromptVariable, naming it, as the async with block opens, so no model call is made. DecimalAI fills only the prompt, never a skill’s text, and the trace keeps the placeholder names, not their values.
Conversations
For a chat, keep onesupport.conversation() beside its history, and run its messages one at a time:
- A conversation keeps its first message’s prompt, variables and
load_skilldefinition, and resumes its own Claude session. That is what a chat on Claude requires. A newer saved prompt or skill list reaches the next conversation. - A later message’s new skills go in after the user’s text, when the agent has more skills than one list holds and that message’s ranking picks ones the chat has not shown.
- It lives in this process. Unlike the other frameworks, it has no
stateto store, so a chat can’t continue after a restart or in another process. - Variables belong to the conversation.
chat.run()takes only the message.
Its own skill loader
Claude Code reads skills from disk itself, anddecimalai skills keeps .agents/ as a Claude Code plugin named decimalai-skills. decimalai.claude_agent_sdk.skills_plugin() passes that folder to the Agent SDK:
- Keep this apart from
agent_config(). Use one per agent, or the model sees a skill twice.run.query()refusesskills=. - Claude Code picks the skill. A trace on this path has no DecimalAI ranking. With the stream traced, each skill text the CLI hands the model counts as Loaded, with the version found from the lock, and the DecimalAI skills in its catalog count as Offered.
- Names carry the plugin’s prefix:
decimalai-skills:playwright-cli.skills="all"also offers Claude Code’s built-in skills. To offer only yours, list them:skills=["decimalai-skills:playwright-cli"]. A skill left off the list is hidden, and nothing reports it. - Only skills your organization wrote pre-approve tools. For any other, only
Read,GrepandGlobstay in itsallowed-tools, so running its scripts needs your permission.
--plugin-dir started from a subdirectory loads nothing and shows no error.
Tracing
With a key, eachrun.query() is one trace, filed under support.name. With no key, nothing is traced. A trace holds:
- Every assistant turn as a model call, and tool calls matched to their results, with latency and per-tool error status. A failed tool doesn’t fail the run: the
ResultMessagedecides. - Token usage and cost from the final
ResultMessage, including cache tokens. - The agent’s manifest (the record of its model, prompt, allowed tools by name, and sub-agents), detected from your options. For tool schemas, use
register_manifest(). - On
agent_config()runs: the saved prompt version, the ranking decision, and the skills offered, delivered and loaded, with the versions the model got.
Tracing only
To trace ordinaryquery() calls with no prompt or skills from DecimalAI, use the framework flag. It patches claude_agent_sdk.query, so call it before from claude_agent_sdk import query:
ClaudeSDKClient.receive_response(), with trace_stream. traced_query(prompt=..., options=..., agent_name=...) calls query() and wraps it in one step:
Troubleshooting
raw Claude resume, session_id and continue_conversation options bypass config. A session under a different prompt breaks Claude’s thinking history. Usesupport.conversation().Claude config supplies routed skills; do not also enable native skills. Removeskills=from the options you pass torun.query(). For disk skills, use the loader on its own.mcp_servers['decimalai'] is reserved, orClaude config needs mcp_servers as a dict. Pass your servers as dictionary entries under other names.load_skill is disallowed by these Claude options. Takemcp__decimalai__load_skillout ofdisallowed_tools.consume run.query() inside 'async with support.run(question) as run:'. Read the stream inside the block.each Claude config run can query only once. Start anothersupport.run()for each message.run a Claude conversation's messages sequentially. Two messages of one conversation overlapped. Wait for the first.- Your
system_prompthas no effect.run.query()replaces it. Put your code’s prompt inagent_config(..., fallback=...). - A run stops early after adding skills. Each
load_skillcall is one more turn. Leave room undermax_turns. - A
query()isn’t traced underinit(claude_agent_sdk=True). You importedqueryby name before callinginit(), so you hold the unpatched function.DECIMAL_AUTO_TRACEhas no value for this framework: use the flag in code. - The model never loads a skill. After a run,
support.skill_nameslists the skills on its list. With no key, an empty list means.decimal/skills.tomllists nothing. With a key, check that the agent gets the skill. - No
load_skilltool on the run. The tool is added only when the run lists skills. WithDECIMALAI_LOAD_SKILL_TOOL=0ordecimalai.init(load_skill_tool=False), the text of the skills picked for each run goes into the system text instead. The other switches are in Turn it off.