Skip to main content

A3S Code - Native Python bindings for the coding-agent runtime

Project description

A3S Code — Python SDK

Native Python bindings for the A3S Code AI coding agent, built with PyO3.

Installation

pip install a3s-code

Quick Start

from a3s_code import Agent

agent = Agent.create("agent.acl")
session = agent.session("/my-project")

result = session.send("What files handle authentication?")
print(result.text)

Slash Commands

Every session includes built-in slash commands dispatched before the LLM:

# List all available commands
commands = session.list_commands()
for cmd in commands:
    print(f"/{cmd['name']:15s} {cmd['description']}")

# Built-in commands
result = session.send("/help")       # List all commands
result = session.send("/model")      # Show current model
result = session.send("/cost")       # Token usage and cost
result = session.send("/history")    # Conversation stats

Custom Commands

def my_handler(args: str, ctx: dict) -> str:
    return f"Model: {ctx['model']}, History: {ctx['history_len']} msgs, args: {args!r}"

session.register_command("status", "Show session info", my_handler)
result = session.send("/status hello")

Full API

from a3s_code import (
    Agent,
    SessionOptions,
    DefaultSecurityProvider,
    FileMemoryStore,
    FileSessionStore,
)

agent = Agent.create("agent.acl")
session = agent.session("/my-project",
    model="openai/gpt-4o",
    builtin_skills=True,
    planning_mode="auto",  # "enabled" forces planning, "disabled" turns it off
)

# Send / Stream
result = session.send("Explain the auth module")
for event in session.stream("Refactor auth"):
    if event.event_type == "text_delta":
        print(event.text, end="", flush=True)

# Streams with no custom history update session history and verification evidence
# when the stream completes. Passing explicit history keeps the stream isolated.

# Planning events
# Prefer planning_mode="auto" | "enabled" | "disabled". The legacy planning
# bool still works: True forces planning, False disables it. In streaming mode,
# render task_updated as the current task list; step_start and step_end are
# per-step progress events.

# Run replay
runs = session.runs()
if runs:
    print(runs[-1]["id"], runs[-1]["status"])
    print(session.run_events(runs[-1]["id"]))
    # Cancels only if that run is still active; stale IDs are ignored.
    session.cancel_run(runs[-1]["id"])

# Direct tools (bypass LLM)
session.read_file("src/main.py")
session.bash("pytest")
session.glob("**/*.py")
session.grep("TODO")
session.tool_names()
session.tool_definitions()

# Programmatic Tool Calling (embedded QuickJS)
program = session.program({
    "source": """
        export default async function run(ctx, inputs) {
          const hits = await ctx.grep(inputs.query, { glob: '*.py' });
          const files = await ctx.glob('src/**/*.py');
          return { hits, files: files.slice(0, 10) };
        }
    """,
    "inputs": {"query": "PermissionPolicy"},
    "allowed_tools": ["grep", "glob"],
    "limits": {"timeoutMs": 30000, "maxToolCalls": 20, "maxOutputBytes": 65536},
})
print(program.output)

# Delegation helpers (wrappers around task / parallel_task)
session.delegate_task(
    agent="explore",
    description="Find auth entry points",
    prompt="Inspect the repository and summarize the auth-related files.",
)
session.parallel_task([
    {"agent": "explore", "description": "Find tests", "prompt": "Locate auth tests."},
    {"agent": "verification", "description": "Check risk", "prompt": "Review auth edge cases."},
])

# Slash commands
session.list_commands()
session.register_command("ping", "Pong!", lambda args, ctx: "pong")

# Memory
session.remember_success("task", ["tool"], "result")
session.recall_similar("auth", 5)

# Hooks
session.register_hook("audit", "pre_tool_use", handler_fn)

# MCP
session.add_mcp_server("github", command="npx", args=["-y", "@modelcontextprotocol/server-github"])
session.mcp_status()
session.tool_names()
session.remove_mcp_server("github")

# Persistence
opts = SessionOptions()
opts.session_store = FileSessionStore('./sessions')
opts.session_id = 'my-session'
opts.auto_save = True
session2 = agent.session(".", opts)
resumed = agent.resume_session('my-session', opts)

Delegation

Routine multi-agent work uses the model-visible task and parallel_task tools. Use session.delegate_task(...) and session.parallel_task(...) for SDK-native calls, or session.tool("task", {...}) when you need raw access. The old standalone lifecycle control-plane API is intentionally removed from the 2.0 SDK surface.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

a3s_code-2.2.0-cp313-cp313-win_amd64.whl (12.3 MB view details)

Uploaded CPython 3.13Windows x86-64

a3s_code-2.2.0-cp313-cp313-manylinux_2_28_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

a3s_code-2.2.0-cp313-cp313-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

a3s_code-2.2.0-cp312-cp312-win_amd64.whl (12.3 MB view details)

Uploaded CPython 3.12Windows x86-64

a3s_code-2.2.0-cp312-cp312-manylinux_2_28_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

a3s_code-2.2.0-cp312-cp312-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

a3s_code-2.2.0-cp311-cp311-win_amd64.whl (12.3 MB view details)

Uploaded CPython 3.11Windows x86-64

a3s_code-2.2.0-cp311-cp311-manylinux_2_28_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

a3s_code-2.2.0-cp311-cp311-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

a3s_code-2.2.0-cp310-cp310-win_amd64.whl (12.3 MB view details)

Uploaded CPython 3.10Windows x86-64

a3s_code-2.2.0-cp310-cp310-manylinux_2_28_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

a3s_code-2.2.0-cp310-cp310-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file a3s_code-2.2.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: a3s_code-2.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 12.3 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for a3s_code-2.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c9a45ef3a80fae9c6ea80e66d428282740a90143730b22941227a8c8ac814f22
MD5 a6593a0a33a95b6d529a3ad8f81ccbf0
BLAKE2b-256 13dad1c0e4d314c337e011f7785fd32116d35558d8c560e53ba4bf8b62935499

See more details on using hashes here.

File details

Details for the file a3s_code-2.2.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for a3s_code-2.2.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3e12ce72713eb03907d0d4555363a71fc68ebf7801997550f07d6b1121c23b58
MD5 0f099e0eff3e794f6cbb4f4ecc57352f
BLAKE2b-256 0152009cfeb06d9163fa9bb673fc2883b353f2e1f0bf94274809319e6fc64fff

See more details on using hashes here.

File details

Details for the file a3s_code-2.2.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for a3s_code-2.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 917fa0b7936cf0ac4fe786e2f00bed35dd9d6a31fae901ca96bfc746b95ccb2a
MD5 74264976e524e5d2f43d1480b7d519fb
BLAKE2b-256 19f9c23216737c3e245c0d855cd196fb45c6dc063d7253eb94a9a52b677f2ac5

See more details on using hashes here.

File details

Details for the file a3s_code-2.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: a3s_code-2.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 12.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for a3s_code-2.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 993c9ccddc252cb0e35622958fd61ec813b49d4d3ad4102bb6beb907704aab0f
MD5 a6704e8a6feb43ebfd130accfd47e881
BLAKE2b-256 a7bacca597d4760d448fa0431f76775151e95eacb8ca1c26e0fa97cd9be14dff

See more details on using hashes here.

File details

Details for the file a3s_code-2.2.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for a3s_code-2.2.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4ec865eaa80875068f8964f45d4948bfbb360fcfde91f1614d5f025cb909e27a
MD5 e8f7c2fc5aa638dc3dd125383947b6fb
BLAKE2b-256 2761c8a664145b64e6842b4db64301260b9536e52d7fc3c884481fa818e4a24f

See more details on using hashes here.

File details

Details for the file a3s_code-2.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for a3s_code-2.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 46f22668a0887cdf02a3383d91aad46dd809baf18fdcd150eb5f39deb04941a6
MD5 3689f3939ba75242748826cef24e8de3
BLAKE2b-256 299e58ab80479981cc5993a0ed07d11768a666db4918e13ed5ed4bab4a1b71d4

See more details on using hashes here.

File details

Details for the file a3s_code-2.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: a3s_code-2.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 12.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for a3s_code-2.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7b5b69ede6ce8f7c1be9188b0b2e4ed04dfa8a868db3ddd052951777163194d5
MD5 2b0149e0ac9d1c9ead82f3b8d614fdd9
BLAKE2b-256 b19bf7ae1bc2e26d169a1c177c7436f76c3ec6b0776549ecfd3f944e7482dda4

See more details on using hashes here.

File details

Details for the file a3s_code-2.2.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for a3s_code-2.2.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 57f3593c33a93e8c292e74ac0e14a5325efac27ea2a348251f0eb6f70aefac33
MD5 25c46113f71891056f47e3dd7b005ef0
BLAKE2b-256 0716d5faa39f650fee06cabbc3c0c90b63796d88622068c74c749378ca5da5f6

See more details on using hashes here.

File details

Details for the file a3s_code-2.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for a3s_code-2.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 edbd742627e4de8f866eacb7435368ae6236ef489a4ad2d79f4a763361ccc9a9
MD5 3a49dd92175d94ebfa3aeada56308b1f
BLAKE2b-256 5b6294eadc8bcfea49c64d5dbf06ec5f2ceac20afb1ddd2443f77b2f90b825f0

See more details on using hashes here.

File details

Details for the file a3s_code-2.2.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: a3s_code-2.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 12.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for a3s_code-2.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ecf4bc99bf7e3a780e1ca073ef7a015c040c7fe845b4f2b4dfd421840e80510c
MD5 be3801fb711f946601f35741deae1bbf
BLAKE2b-256 21045b5ba8537f785d57a83c2ad5078faf8f77e1265de3b2d5c80b04fadd0a84

See more details on using hashes here.

File details

Details for the file a3s_code-2.2.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for a3s_code-2.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b9a54b8ec6063ff4e7f46c54a10ef984c4401f4eda4883e485049f5089e961c3
MD5 404b284c6b2d283bc996146af022957b
BLAKE2b-256 335d84e5db666708b2d6f787c0120d4a9e7ea07db63b2b9785d363ee66872425

See more details on using hashes here.

File details

Details for the file a3s_code-2.2.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for a3s_code-2.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 97610633c249ed4687dca2311fb0e3645c709520a2f3ee9d2fb27fffb636a589
MD5 deba5b943ecd9e770c4e1700cf4234ea
BLAKE2b-256 a37053001aa123aa3602a7877cf8e0c707b6e223ec3481329b7bb1451d384005

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page