Build an agent in code
The Autessa CDK is in preview and not yet released. Chatting with Autessa's models from your machine needs a platform update that is still rolling out. Until it reaches your company, chat says so and you can use --stub.
Write an agent in a few lines: its instructions, its model, its tools and its firewall. Test it offline, chat with it on your machine, then deploy the same code to Autessa unchanged.
The loop
init agent <name>writes a working project.testruns its test cases offline, with the model stubbed.chattalks to the agent on your machine. Autessa's models answer, and the project's tools run locally.diffshows what a deploy would change in a stage.deployputs it on Autessa.
- TypeScript
- Python
- Java
npx autessa-cdk init agent order-helper
cd order-helper
npx autessa-cdk test
npx autessa-cdk chat OrderHelper
npx autessa-cdk diff --stage dev
npx autessa-cdk deploy --stage dev
autessa-cdk init agent order-helper
cd order-helper
autessa-cdk test
autessa-cdk chat OrderHelperAgent
autessa-cdk diff --stage dev
autessa-cdk deploy --stage dev
mvn com.autessa:autessa-cdk-maven-plugin:0.1.0-SNAPSHOT:init -Dautessa.template=agent -Dautessa.name=order-helper
cd order-helper
mvn autessa-cdk:test
mvn autessa-cdk:chat -Dautessa.agent=OrderHelper
mvn autessa-cdk:diff -Dautessa.stage=dev
mvn autessa-cdk:deploy -Dautessa.stage=dev
Gradle: gradle autessaInit -Pautessa.template=agent -Pautessa.name=order-helper, then autessaTest, autessaChat -Pautessa.agent=OrderHelper, autessaDiff and autessaDeploy.
To install the CDK, see Autessa CDK.
What init writes
init agent <name> makes a folder named <name> with:
- the project config with one
Agent, oneTool(tools/lookup.as) and aFirewallPolicy; autessa.stages.yamlwith adevstage;tests/agent.test.yaml, whose cases stub the model so they run offline;- a README with the next steps:
test,chat,diff,deploy.
It never overwrites a file that is already there. The agent's logical ID comes from the name: order-helper becomes OrderHelper (OrderHelperAgent in Python).
The agent in a few lines
An Agent takes four settings at the top level:
| Setting | What it is |
|---|---|
instructions | What the agent does, in plain words. |
model | small, large, or a model from your company's catalog. |
tools | The project's Tools the agent may call. |
firewall | A FirewallPolicy, or its settings. Settings make a policy named <agent>Firewall for you. |
- TypeScript
- Python
- Java
// autessa.config.ts
import { Agent, Project, Tool } from "@autessa/cdk";
const project = new Project({ name: "order-helper" });
const lookup = new Tool(project, "Lookup", {
source: "tools/lookup.as",
description: "Look up an order by id",
inputSchema: { type: "object", properties: { orderId: { type: "string" } } },
});
new Agent(project, "OrderHelper", {
instructions: "You help customers with their orders. Look the order up before you answer.",
model: "small",
tools: [lookup],
firewall: { policy: { mode: "ENFORCE", blockPromptInjection: true } },
});
export default project;
# autessa.config.py
from autessa.cdk import Agent, Project, Tool
project = Project("order-helper")
lookup = Tool(project, "Lookup", source="tools/lookup.as")
Agent(project, "OrderHelperAgent",
instructions="You help customers with their orders. Look the order up before you answer.",
model="small", tools=[lookup], firewall={"mode": "ENFORCE"})
Tool lookup = p.tool("Lookup").source("tools/lookup.as");
p.agent("OrderHelper")
.instructions("You help customers with their orders. Look the order up before you answer.")
.model("small") // small, large or a model catalog slug
.tools(lookup)
.firewall(Map.of("mode", "ENFORCE")); // or a FirewallPolicy
Any other agent setting goes in the agent passthrough (agent: { ... } in TypeScript, agent={...} in Python, .property(key, value) in Java). A key set there wins over the shorthand. memory turns on conversation memory.
Test it offline
test runs tests/**/*.test.yaml against a local fake Autessa: no account, no network. An agent case stubs each model turn, and a stubbed reply can call tools:
- name: the agent looks the order up, then answers
run: OrderHelper
inputs: { message: "Where is my order A1001?" }
stubs:
agents:
- when: { agent: OrderHelper, turn: 1 }
reply: { toolCalls: [{ name: Lookup, arguments: { orderId: A1001 } }] }
- when: { agent: OrderHelper, turn: 2 }
reply: Order A1001 has shipped.
expect:
responseText: { $contains: shipped }
calls: { tool: { contains: [{ tool: Lookup, inputs: { orderId: A1001 } }] } }
Tests stay stubbed, so they are repeatable. Add models: autessa to a case or a file to run it on Autessa's models instead. test --before-deploy runs the checks a deploy runs first.
Chat with it on your machine
chat <AgentLogicalId> runs the agent locally:
- Each model turn goes to Autessa's models, with the agent's instructions, model, the conversation so far and its tools' schemas.
- Each tool call runs on your machine, against the project's tools, and is printed as it runs.
- The loop ends at a reply with no tool calls, or at the agent's
maxIterations.
It needs one of these, set in your environment and never in project files:
AUTESSA_DEPLOY_KEY: a deploy key with Run agents locally (MODEL_TURN).AUTESSA_API_KEY: an API key with the Run agents locally permission (AGENT_MODEL_TURN). Only a company admin can give a key this permission.
See Keys.
Turns are billed to your company like an agent run, and your company's firewall policy checks each message and reply.
| Option | TypeScript | Python | Maven / Gradle |
|---|---|---|---|
| Stubbed replies, no key | --stub | --stub | autessa.models=stub |
| Send one message and exit | --message "text" | -m "text" | |
| Chat in a stage's tenant instead | --stage dev | --stage dev | autessa.stage=dev |
If your company doesn't have Autessa's model endpoint yet, chat stops with: Autessa's model endpoint isn't available on this server yet. Use --stub to run with stubbed replies. It never falls back to stubs on its own.
Some agents only run in a tenant: ones that search a knowledge table, use an MCP server, or call built-in tools such as email or the phone keypad. For those, chat stops with: This agent uses features that run only in Autessa. Run it with --stage <name> to chat with it in that stage's tenant.
Chat with it in a stage's tenant
chat <AgentLogicalId> --stage dev chats with the agent in that stage's tenant. Its tools, knowledge table and MCP server are the ones you deployed there, and they run in Autessa. Each tool call is printed as on your machine.
- Deploy first. The agent's tools, table and MCP server must already be deployed to the stage. If one isn't,
chatnames it and stops. - The stage's deploy key.
chatuses the stage's deploy key (itsdeployKeyEnv, thenAUTESSA_DEPLOY_KEY). The key needs the Chat with agents from your machine permission (HARNESS_CHAT). On its own, that permission can't deploy, pull or roll back anything. - One agent for chats. The first time,
chatcreates an agent namedlocal-harness-agentin the tenant. After that, it gives that agent the settings of whichever agent you chat with, including its firewall policy and the stage's variable values. If the tenant already has an agent with that name thatchatdidn't create,chatleaves it alone and asks you to rename it. - Nothing is deployed. Deploy history, rollback and sharing don't change.
- Billing. Conversations are billed to the tenant like any agent conversation.
Diff and deploy
diff --stage dev asks Autessa what the deploy would create, update or delete, and marks any change that widens access. deploy --stage dev applies it. The agent runs on Autessa exactly as written, with its tools and its firewall policy. See Commands for every flag, and Watch deployments to follow a deploy in Autessa.
To call the deployed agent from your app, use the agents package.