@@ -69,7 +69,9 @@ from a3s_code import Agent
6969agent = Agent.create(" agent.acl" )
7070session = agent.session(" /my-project" )
7171
72- result = session.send(" Find where authentication errors are handled and summarize the flow" )
72+ result = session.send({
73+ " prompt" : " Find where authentication errors are handled and summarize the flow" ,
74+ })
7375print (result.text)
7476```
7577
@@ -81,7 +83,9 @@ import { Agent } from '@a3s-lab/code';
8183const agent = await Agent .create (' agent.acl' );
8284const session = agent .session (' /my-project' );
8385
84- const result = await session .send (' Find where authentication errors are handled and summarize the flow' );
86+ const result = await session .send ({
87+ prompt: ' Find where authentication errors are handled and summarize the flow' ,
88+ });
8589console .log (result .text );
8690
8791session .close ();
@@ -140,6 +144,7 @@ Default core tools:
140144| Files | ` read ` , ` write ` , ` edit ` , ` patch ` |
141145| Search | ` grep ` , ` glob ` , ` ls ` |
142146| Shell | ` bash ` |
147+ | Programmatic | ` program ` |
143148| Delegation | ` task ` , ` parallel_task ` |
144149| Skills | ` search_skills ` , ` Skill ` |
145150
@@ -188,26 +193,53 @@ script can call every registered tool except `program`; use `allowedTools` or
188193structured summaries, findings, artifact references, and suggested next actions.
189194Raw output belongs in trace storage.
190195
196+ ### 5. AHP-Supervised Background Advice
197+
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.
201+
202+ Attach an AHP hook executor to forward lifecycle hooks and durable run events to
203+ the harness:
204+
205+ ``` python
206+ from a3s_code import Agent, HttpTransport, SessionOptions
207+
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+ ```
214+
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.
220+
191221Node and Python expose the same session controls as the Rust core:
192222
193223``` js
194224agent .session (' /repo' , { planningMode: ' disabled' }) // auto | enabled | disabled
195- await session .delegateTask ({
225+ await session .task ({
196226 agent: ' explore' ,
197227 description: ' Find auth files' ,
198228 prompt: ' Inspect auth-related files and return evidence.' ,
199229})
200230console .log (session .toolDefinitions ())
231+ await session .git ({ command: ' status' })
201232```
202233
203234``` python
204235session = agent.session(" /repo" , planning_mode = " enabled" )
205- session.delegate_task(
206- agent = " verification" ,
207- description = " Check release risk" ,
208- prompt = " Validate the current changes and summarize blockers." ,
209- )
236+ session.task({
237+ " agent" : " verification" ,
238+ " description" : " Check release risk" ,
239+ " prompt" : " Validate the current changes and summarize blockers." ,
240+ } )
210241session.tool_definitions()
242+ session.git({" command" : " status" })
211243```
212244
213245Planning is explicit and observable. In ` auto ` mode the runtime performs
@@ -225,6 +257,7 @@ const latest = runs.at(-1)
225257if (latest) {
226258 console .log (await session .runSnapshot (latest .id ))
227259 console .log (await session .runEvents (latest .id ))
260+ console .log (await session .activeTools ())
228261 await session .cancelRun (latest .id )
229262}
230263```
@@ -236,6 +269,7 @@ latest = runs[-1] if runs else None
236269if latest:
237270 print (session.run_snapshot(latest[" id" ]))
238271 print (session.run_events(latest[" id" ]))
272+ print (session.active_tools())
239273 session.cancel_run(latest[" id" ])
240274```
241275
@@ -514,6 +548,17 @@ mcp_servers = [
514548
515549MCP tools are selected per turn instead of being listed wholesale in the system prompt.
516550
551+ SDK callers can also attach MCP servers to a live session with object-shaped
552+ configs:
553+
554+ ``` js
555+ await session .addMcp ({
556+ name: ' github' ,
557+ transport: { type: ' stdio' , command: ' npx' , args: [' -y' , ' @modelcontextprotocol/server-github' ] },
558+ timeoutMs: 30000 ,
559+ })
560+ ```
561+
517562---
518563
519564## Slash Commands
@@ -527,7 +572,6 @@ Sessions support slash commands:
527572| ` /cost ` | Show token usage |
528573| ` /clear ` | Clear conversation history |
529574| ` /compact ` | Manually trigger context compaction |
530- | ` /btw <question> ` | Ask a side question without polluting history |
531575
532576---
533577
@@ -576,6 +620,7 @@ cargo build -p a3s-code-node
576620
577621Full reference and guides: [ a3s.dev/docs/code] ( https://a3s.dev/docs/code )
578622
623+ - [ SDK API Design Contract] ( manual/SDK_API_DESIGN.md )
579624- [ Sessions] ( https://a3s.dev/docs/code/sessions )
580625- [ AHP Protocol] ( https://a3s.dev/docs/code/ahp )
581626- [ Tools] ( https://a3s.dev/docs/code/tools )
0 commit comments