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.1.0-cp313-cp313-win_amd64.whl (12.3 MB view details)

Uploaded CPython 3.13Windows x86-64

a3s_code-2.1.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.1.0-cp313-cp313-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

a3s_code-2.1.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.1.0-cp312-cp312-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

a3s_code-2.1.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.1.0-cp311-cp311-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

a3s_code-2.1.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.1.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.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: a3s_code-2.1.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.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 63e140c0611ed0d5ef9800c1b92af2ea68921ec302af2776f7e53b640f0b124b
MD5 187d9393f3a71d1cd00735137df9ffe0
BLAKE2b-256 470204eb1cd51acef536a6b2363a908b900ab68cd0632f35020ce2061c6566fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a3s_code-2.1.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 176f612e038f70346533cff86efa2e00a92f0a96c8b8163d654d86a99c0cf25a
MD5 c02a4bb8587b059c164c536835e8f44d
BLAKE2b-256 130e22b6d670b20516875f1e58d7887a357a6ec9ae5e8141f60e0f328803ea39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a3s_code-2.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3aa45ebd687d63b0c12614395f504a8faa8ffbbd7358e692b0b6978ac020b708
MD5 bea20190826861a4fe1c11d4d264958f
BLAKE2b-256 62c02a80139f4781bb5bb46ef1e9afbd401707b53851e2238ea1ed74ba2f487f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a3s_code-2.1.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.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4f86376b54e6a2becdd0baf7dd8858b12f244984555cf6be18e2204a5b5bea3a
MD5 d379caf62ffe803ad95dbfc0117fc6e1
BLAKE2b-256 7b0c9145653206cd1739f7344a6422ceca34c88181b1bfbaa35735cd8f0ae757

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a3s_code-2.1.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9160b88540ea599ab70b61af2af1b50f13cc4733605731f3e3a4214efb272fbb
MD5 8c187d49cebd1cec28560538a34f5a08
BLAKE2b-256 7a53bbcc86e51a3454c8430de9c5f079d7afe83158fd40c2c534e6ba8d596c8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a3s_code-2.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 99d811a1c2edd16e16e34d1c485b286e691e8e1f31698704946bdfd5ebd6efda
MD5 101c56d0dd85bf3a21c29cbfc2477d8c
BLAKE2b-256 e16fa27ae19ab58dd0a662aace1cbd173e7d458f26f2953e3e96cc7954495f97

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a3s_code-2.1.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.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b8a1897da27739a9d1c69fd01afd43470c6af379de1911be3a3acb072bca1087
MD5 6468a3fdc4e35fbf22ee289568042ce6
BLAKE2b-256 685db68e7a8347f66f0494f05e7631f4cdea7d2c0e6a2d9e692b104c49ebf2d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a3s_code-2.1.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 136667b073db4c56b268308411b72dccf314bdad138f75e5be7bbaff94dfbc2f
MD5 3141ee44e8bfb67689c1ad0753b2a29c
BLAKE2b-256 b16a6789b6f8016e7e6818bc5987b4b40790baab223cc8c475f6ccf847063446

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a3s_code-2.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8a7cb0a4dbd1aa7650014ab77a5821a7a2cfb9775283553a3133fb45a263b5af
MD5 49a0655c6243848d3edc6a6713d71d97
BLAKE2b-256 47a37ebdc8ed08ca9ddcc6c27b37ce74c0766e5e54f9a3b4c66a784888485f43

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a3s_code-2.1.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.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f271e0eb271a2306976657bc76e86d7ff1665aedc04982eb19ccaace7c9770ac
MD5 f010e3de4a42fdbb7a532c32669cd41a
BLAKE2b-256 27c12ebf3085ed8c3d3d891f6a3dbfbbb2ff9874522a859f30fe9e3d1bca34d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a3s_code-2.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6a432b63fbb4689c93ab5459f372f8dd5148664ada83a79f88b33477bde2f57f
MD5 182aa53b33a13ff6a257aace7322b4de
BLAKE2b-256 d64986230f38c281ce8cb303b60d1ef7b49701c63be64cec6d58d2491e28967b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a3s_code-2.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03481cb9efc25bf093e9a4cd7b8589b681096810a5d54eb84a2311cddabc9508
MD5 161a3beacac421e8e143c7c501996b36
BLAKE2b-256 abe96b40eed28cbaf62ccf3bbc64158fcecb58b10e5c8ddd0acbac1316869a03

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