Browse documentation
aner.agent · Reference

Call an approved Aner prediction from an external notebook

Request an energy prediction from an Aner notebook and verify the receipt and a denied request offline.

Released in Aner 0.1.2Aner 0.1.2 or newer

A scientist approves observation 401 in a local Aner project. A colleague opens an Aner notebook and requests the prediction through the Model Context Protocol (MCP). A reviewer can verify the returned measurement and the denial of row 402 offline. The service and original portable export were introduced by 0.1.2-dev.5. The native client and verifier require Aner 0.1.2 on macOS or Linux. Scientific agent reference

Prepare and approve the run in Aner

The scientist approves row 401 in Aner. The notebook receives a scope error for row 402 and a prediction with its receipt ID for row 401.

Use one local project directory for the example. Save the proposal script as examples/agent_energy.aner, the MCP service as examples/agent_energy_mcp.aner, and the energy data as examples/fixtures/contextual/energy.csv. Start with a fresh directory for each independent study.

From the project root, run the following command with local Ollama serving qwen2.5:14b-instruct. The script fits the training buildings, obtains a proposal and creates a private journal named energy-401.run.

Run aner run examples/agent_energy.aner --prod from the project root.

In an Aner notebook opened at the same project root, inspect the tool, row, fitted input identity and current state.

aner
import aner.agent
let reviewed = agent.open_run("energy-401.run")
print(reviewed.replay())

If you intend to authorize that prediction, run this separate cell. Keep the journal on the original local filesystem.

aner
print(reviewed.approve())

The MCP service opens this journal, rebuilds the fitted inputs from the project and calls agent.serve_mcp(run, fit, scaler, split.validation(), true). The final argument enables local telemetry for returned predictions and row scope denials. The external client starts that dedicated Aner program as a child process. Its standard input and output carry protocol messages, so keep print statements out of the service program. Subsequent tool calls can run with Ollama offline. Native approval and recovery guide

Call the tool from an Aner notebook

Open the external notebook in the Aner editor at the project root. Each call starts the selected local Aner service in a separate process, negotiates a stdio MCP session, discovers the observation tool and submits one row. Choose a service source you trust. Complete runnable example

aner
import aner.agent
let service = "examples/agent_energy_mcp.aner"
print(agent.mcp_prediction(service, 402))
print(agent.mcp_prediction(service, 401))

A successful reply includes the measurement in structuredContent and its receipt in evidence_id. On denial the reply contains isError and a text explanation.

RequestWhat the scientist can observe
Discover toolsOne prediction tool. Its only argument is a string named row_id.
Call the approved rowAn object with row_id, numeric value, unit and evidence_id.
Call another rowA tool error with isError set to true and no prediction payload.
Call the completed row from a fresh clientThe saved result carries the original receipt identity.

The notebook may request an observation. Approval, cancellation, the fitted model and selection of the run stay with the scientist who configured the Aner service. MCP limits the operations exposed by that service. A notebook with operating system access to the project still has the permissions of its local user. The pilot uses one local stdio server and the tools capability of protocol revision 2025-11-25. MCP stdio transport · MCP tools

What the external notebook returned

The verified notebook returned 107.99999999999999 kWh for row 401, the same value and unit as the independent reference. Row 402 belongs to the same validation building. Both its first request and a request after row 401 completed returned requested row is outside the approved prediction scope. Neither changed the native journal.

A second study added 37 kWh to every training target and changed row 401’s measured energy to −999 kWh. The notebook returned 145 kWh, as the changed fit predicted. Each study produced one native receipt. Reconnecting to the completed run returned the original receipt ID. Newly created studies receive their own receipt IDs. Tool schema and recorded request and response pairs

Export the run for a reviewer

After the notebook finishes, run the export program from the same project directory. It opens the existing journal, writes a snapshot to a fresh directory, and prints the SHA-256 digest of the exact manifest bytes.

Run aner run examples/agent_export_run.aner --prod from the project root.

aner
import aner.agent

let run = agent.open_run("energy-401.run")
print(agent.export_run(run, "energy-401-evidence"))

The directory name must be new for each export. Keep the printed digest in a trusted lab record or send it to the reviewer separately. Copy the two files together. The recipient can rename or move their enclosing directory.

FileEvidence it carries
manifest.jsonThe run and approved row, proposal model name, runtime, fitted input identity, journal entries, recorded value and unit, and the telemetry digest.
telemetry.jsonlOrdered observations of the audited MCP service. A returned prediction refers to its native receipt. A scope denial identifies the requested row and has no measurement.

Telemetry begins when the service is run with the final argument set to true. It records each eligible server decision before writing the MCP reply. Evidence that a client actually received the reply must come from the client or a transport observer. With four arguments, the service omits this telemetry. A later export cannot supply evidence of a denial that went unrecorded. A repeated call for a completed row can produce another telemetry entry for the same native receipt.

Verify offline

Send the two evidence files together and the manifest digest separately. The reviewer checks the receipt and the recorded scope denial offline.

Save the sample manifest and sample telemetry in a directory named energy-401-evidence. Open the Aner verifier example or run this Aner cell with Aner 0.1.2.

aner
import aner.agent
print(agent.verify_run("energy-401-evidence",
    "e0a97d8669dc7537339dd78d0eff346adf2706efd5c393b19fa97687c7e01283",
    401, 402, 108.0, "kWh"))

For a new study supply the separately retained digest and your expected value and unit. The verifier checks the manifest, the journal transitions and receipt hash, the telemetry digest, the returned measurement and the requested scope denial. The expected value uses an absolute tolerance of 0.000000001. The sample reports "verified":true, two returns and two denials. The reviewer needs only the Aner runtime, the portable files and the trusted expectations.

An external notebook can also act as a named specialist with a limited number of submissions. Its native grant, remaining allowance and receipt are shared with the Aner specialist. Delegate an approved energy prediction

Aner documentation · Reference and guides