A3S Docs
A3S CodeExamples

Batch

Compose deterministic SDK helpers for grouped, model-free operations

Batch

There is no batch() method in the SDK. When a host workflow or agent turn has a clear list of independent, deterministic steps, compose them directly from the session's deterministic helpers (readFile, grep, glob, ls, git) and aggregate the results yourself. That keeps the "batch" fully under your control: no model calls, explicit ordering, and no destructive operations unless you invoke them.

The example below reads package metadata, the changelog, and the release script, then reports version mismatches without editing any files.

import { Agent } from '@a3s-lab/code';

const agent = await Agent.create('agent.acl');
const session = agent.session('/path/to/project');

// Node helpers are async — group independent reads with Promise.all.
const [pkg, changelog, releaseScript] = await Promise.all([
  session.readFile('package.json'),
  session.readFile('CHANGELOG.md'),
  session.readFile('scripts/release.sh'),
]);

const pkgVersion = JSON.parse(pkg).version;
const mismatches = [];
if (!changelog.includes(pkgVersion)) mismatches.push(`CHANGELOG.md is missing ${pkgVersion}`);
if (!releaseScript.includes(pkgVersion)) mismatches.push(`release.sh is missing ${pkgVersion}`);

console.log(mismatches.length ? mismatches.join('\n') : 'All files agree on the version.');

await session.close();
import json
from a3s_code import Agent, SessionOptions

agent = Agent.create(open("agent.acl").read())
session = agent.session("/path/to/project", SessionOptions())

# Python helpers are synchronous — call them in sequence, no await.
pkg = session.read_file("package.json")
changelog = session.read_file("CHANGELOG.md")
release_script = session.read_file("scripts/release.sh")

pkg_version = json.loads(pkg)["version"]
mismatches = []
if pkg_version not in changelog:
    mismatches.append(f"CHANGELOG.md is missing {pkg_version}")
if pkg_version not in release_script:
    mismatches.append(f"release.sh is missing {pkg_version}")

print("\n".join(mismatches) if mismatches else "All files agree on the version.")

session.close()

Do not mix destructive operations into these grouped reads. Any destructive host workflow (writes, git commits, bash) should sit behind explicit application confirmation or your automation gates, constrained with permissionPolicy / permission_policy so no unexpected step runs silently.

When the steps are not independent — each one depends on the previous result and you want an agent to drive them — use session.pipeline(...) instead, which runs the work in stages where each stage receives the prior stage's output.

On this page