Acontext

What is Agent Tool?

Instead of writing custom tools based on Acontext low-level SDKs, Acontext provides ready-to-use tools that integrate seamlessly with popular LLM providers.

Available Tool Sets

Tool SetDescription
Sandbox ToolsExecute code, edit files, export results
Disk ToolsRead and write files to persistent storage
Skill ToolsAccess agent skills and knowledge

How It Works

Quick Example

Init resources

from acontext import AcontextClient
from acontext.agent.sandbox import SANDBOX_TOOLS

client = AcontextClient()
sandbox = client.sandboxes.create()
disk = client.disks.create()
import { AcontextClient, SANDBOX_TOOLS } from '@acontext/acontext';

const client = new AcontextClient();
const sandbox = await client.sandboxes.create();
const disk = await client.disks.create();

Create context for this session

ctx = SANDBOX_TOOLS.format_context(client, sandbox.sandbox_id, disk.id)
const ctx = await SANDBOX_TOOLS.formatContext(client, sandbox.sandbox_id, disk.id);

Inject prompt

context_prompt = ctx.get_context_prompt()
messages = [
    {"role": "system", "content": f"You have sandbox access.\n\n{context_prompt}"},
    {"role": "user", "content": "Run a hello world script"}
]
const contextPrompt = ctx.getContextPrompt();
const messages = [
    { role: "system", content: `You have sandbox access.\n\n${contextPrompt}` },
    { role: "user", content: "Run a hello world script" }
];

Pass tools to LLM

tools = SANDBOX_TOOLS.to_openai_tool_schema()
response = openai_client.chat.completions.create(
    model="gpt-4.1", messages=messages, tools=tools
)
const tools = SANDBOX_TOOLS.toOpenAIToolSchema();
const response = await openai.chat.completions.create({
    model: "gpt-4.1", messages, tools
});

Execute tools

for tc in response.choices[0].message.tool_calls:
    result = SANDBOX_TOOLS.execute_tool(ctx, tc.function.name, json.loads(tc.function.arguments))
for (const tc of response.choices[0].message.tool_calls) {
    const result = await SANDBOX_TOOLS.executeTool(ctx, tc.function.name, JSON.parse(tc.function.arguments));
}

Next Steps

Last updated on

On this page