Skip to content

Commit 8eaf24f

Browse files
committed
docs: clarify run observability and AHP contract
1 parent 769e3cd commit 8eaf24f

1 file changed

Lines changed: 61 additions & 22 deletions

File tree

README.md

Lines changed: 61 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -193,30 +193,38 @@ script can call every registered tool except `program`; use `allowedTools` or
193193
structured summaries, findings, artifact references, and suggested next actions.
194194
Raw output belongs in trace storage.
195195

196-
### 5. AHP-Supervised Background Advice
196+
### 5. Runtime Observability Is A Contract
197197

198-
A3S Code keeps the core session runtime focused on the main agent. Background
199-
advice, context supplements, and proposed PTC scripts are caller-owned AHP
200-
harness behaviors rather than a separate in-core advisory runtime.
198+
Product UIs and harnesses should build from typed runtime state rather than
199+
parsing final answer text. Every `send(...)` or `stream(...)` creates run-scoped
200+
state in the session; when a session store is configured, these records are
201+
persisted with the rest of the session.
201202

202-
Attach an AHP hook executor to forward lifecycle hooks and durable run events to
203-
the harness:
203+
Durable run state has two layers:
204204

205-
```python
206-
from a3s_code import Agent, HttpTransport, SessionOptions
205+
| Record | Purpose |
206+
|--------|---------|
207+
| `RunSnapshot` | Stable per-run state: id, session_id, status, original prompt, timestamps, final result_text or error, and event_count. |
208+
| `RunEventRecord` | Ordered audit trail: sequence, timestamp_ms, and the emitted `AgentEvent`. |
207209

208-
agent = Agent.create("agent.acl")
209-
opts = SessionOptions()
210-
opts.ahp_transport = HttpTransport("http://localhost:8080/ahp")
211-
session = agent.session(".", opts)
212-
result = session.send("Refactor the auth module")
213-
```
210+
The event stream is organized around the agent loop:
214211

215-
The harness can observe run lifecycle, task, verification, tool, confirmation,
216-
idle, and error events; it can maintain its own background workers and publish
217-
advice through the host UI or by explicitly calling session APIs. Proposed PTC
218-
scripts remain proposals until the caller runs them through the normal
219-
`program`, permission, confirmation, and trace paths.
212+
| Loop phase | Representative events |
213+
|------------|-----------------------|
214+
| Intent | `agent_start`, `agent_mode_changed`, `goal_extracted`, `planning_start`, `planning_end`, `task_updated` |
215+
| Context | `context_resolving`, `context_resolved`, `memory_recalled`, `memories_searched`, `context_compacted` |
216+
| Action | `tool_start`, `tool_end`, `permission_denied`, `confirmation_required`, `confirmation_received`, `confirmation_timeout`, `subagent_start`, `subagent_progress`, `subagent_end` |
217+
| Observation | `tool_output_delta`, `tool_end`, `task_updated`, `turn_end`, `error` |
218+
| Verification | `agent_end` with `verification_summary`, plus `verification_reports()` and `verification_summary()` |
219+
| Compaction | `context_compacted` |
220+
221+
Replay boundaries are explicit:
222+
223+
- Replayable means observable and reconstructible, not re-executable.
224+
- Raw LLM messages remain in session history; run records capture state and
225+
runtime events.
226+
- Full raw logs and large outputs should live in trace or artifact storage;
227+
events should stay typed and product-friendly.
220228

221229
Node and Python expose the same session controls as the Rust core:
222230

@@ -273,7 +281,38 @@ if latest:
273281
session.cancel_run(latest["id"])
274282
```
275283

276-
### 5. Delegated Tasks Isolate Context
284+
### 6. AHP-Supervised Background Advice
285+
286+
A3S Code keeps the core session runtime focused on the main agent. Background
287+
advice, context supplements, and proposed PTC scripts are caller-owned AHP
288+
harness behaviors rather than a separate in-core advisory runtime.
289+
290+
Attach an AHP hook executor to forward lifecycle hooks and durable run events to
291+
the harness:
292+
293+
```python
294+
from a3s_code import Agent, HttpTransport, SessionOptions
295+
296+
agent = Agent.create("agent.acl")
297+
opts = SessionOptions()
298+
opts.ahp_transport = HttpTransport("http://localhost:8080/ahp")
299+
session = agent.session(".", opts)
300+
result = session.send("Refactor the auth module")
301+
```
302+
303+
The SDK event stream remains product/UI friendly. When AHP is enabled, selected
304+
runtime events are projected into the harness-facing contract
305+
(`RunLifecycle`, `TaskList`, `Verification`) by `agent_event_to_ahp_events`,
306+
while tool, prompt, confirmation, idle, and error hooks continue to map to AHP
307+
supervision events.
308+
309+
The harness can observe run lifecycle, task, verification, tool, confirmation,
310+
idle, and error events; it can maintain its own background workers and publish
311+
advice through the host UI or by explicitly calling session APIs. Proposed PTC
312+
scripts remain proposals until the caller runs them through the normal
313+
`program`, permission, confirmation, and trace paths.
314+
315+
### 7. Delegated Tasks Isolate Context
277316

278317
Delegated tasks are not there to create more chat. They isolate local work.
279318

@@ -296,7 +335,7 @@ Delegated child runs should return:
296335

297336
The parent should not ingest the full child transcript.
298337

299-
### 6. Safety Has One Gate
338+
### 8. Safety Has One Gate
300339

301340
All side effects should pass through one authorization path.
302341

@@ -308,7 +347,7 @@ Allow | Ask | Deny
308347

309348
This keeps `bash`, writes, network calls, MCP calls, and release actions auditable.
310349

311-
### 7. Completion Requires Verification
350+
### 9. Completion Requires Verification
312351

313352
A coding agent is not done because it produced text. It is done when the goal is satisfied and the result has been checked.
314353

0 commit comments

Comments
 (0)