Skip to main content
Use these focused patterns after the first Agent quickstart. Each function is an independent TypeScript example. Your application passes a configured ModelProvider; installing and configuring that provider is a prerequisite. Live providers make real model requests. For a complete application with setup and commands, use the support tutorial or authenticated API project.

Continue a conversation

This function owns one Agent and an in-memory conversation. It writes an order number in one turn, asks about it in the next, then closes the Agent. It does not survive a process restart.
Expect the second answer to identify ORD-1042. To adapt this for a user-facing application, derive identity from the host and bind the session to that owner. To persist it, choose a storage adapter; do not infer ownership from an arbitrary client-supplied session ID.

Stream into your interface

Host function: the caller owns the Agent and supplies a text sink and cancellation signal. The function forwards text chunks and awaits each write so the sink can apply backpressure. It does not close an Agent borrowed from the caller.
This forwards text only. A hosted protocol must also represent terminal status and errors and cancel work when its connection ends. Use the streaming tutorial or HTTP transport for that full lifecycle.

Project context with an Agent

Host factory: pass a selected directory and model. The returned Agent borrows access to that directory; close the Agent after its runs finish. Read mode does not grant file writes.
These are explicit core Agent capabilities. They do not construct @agentium/harness. For reusable abilities, shared budgets, and controlled execution, use the separate workspace harness project. Verify that the answer names an existing selected file and does not claim an edit occurred. Workspace scoping is a filesystem capability boundary, not OS isolation for arbitrary subprocesses.

Observe a run

Attach observers before execution and keep observations separate from control decisions. The streaming tutorial shows tool events alongside text; the quality-gate project retains correlated traces. Use loop hooks to change execution and execution policy to authorize it.

More patterns