mirrors-sdk@0.6.2. The package supports
ES modules and CommonJS and has no runtime or peer dependencies.
1. Get connection settings
Open your agent in the Mirrors dashboard, then open Agent setup → SDK connection settings. Copy the API URL and agent ID. The agent ID is a generated identifier, not the agent’s display name. Use an agent SDK key withruntime:read and runtime:write permissions. Store
these settings on your server:
2. Install and initialize
3. Capture originals and retrieve context
At your existing user-turn boundary, create a faithful snapshot of the conversation so far. Use one unique trace ID for the whole execution, preserving it across turns. See trace capture for the message format. The helper below returns the system prompt for your existing model call. It does not call the model or change your tool, stream, or error handling.result.freshness.expiresAt before
using a result, or retrieve again.
Context retrieval has a total wait budget of up to 1,000 ms, including copying,
worker scheduling, and transport. A blocked JavaScript event loop can delay timers.
You can shorten the budget with timeoutMs. Do not repeat retrieval at every
internal tool step unless you intentionally want that additional wait.
4. Finish the conversation
After recording the last response and tool results, submit the full final snapshot. Call this at actual conversation completion, not when a stream first opens or a single tool returns.terminal: "failed" or "canceled" when appropriate. These describe how the
execution ended, not whether the agent solved the user’s task. If you have no final
evidence, call releaseTrace(traceId) for local cleanup. Never reuse a finished ID.
5. Verify before activating
Start in shadow mode. Check capture receipts and confirm completed conversations appear in Mirrors.accepted with ingestion queued
means analysis was queued, not finished.
Empty context is expected in shadow mode and while the SDK first learns the agent’s
mode. Review a correction, preview its scope, then deliberately enable active
delivery when ready. See troubleshooting if capture or
retrieval does not behave as expected.