Logging
Status: 2026-11-13. Built and tested: pkg/logging, the log file and the orquelo logs command, Host and plugin instrumentation, forwarding of process-plugin logs, and the convention
Status: 2026-11-13. Built and tested: pkg/logging, the log file and the orquelo logs command, Host and plugin instrumentation, forwarding of process-plugin logs, and the convention check. Not built: shipping logs to a remote store, a follow mode for orquelo logs, and metrics. Run traces and metrics are proposed in run traces and run quality.
Problems in production are investigated mostly by code agents. An agent reads files and runs commands; it does not watch a dashboard. So the log is designed to answer three questions with one command each: what happened in this run, what went wrong recently, and which line of code wrote this record.
1. Where Logs Are
| Sink | Format | For |
|---|---|---|
<log.dir>/orquelo.jsonl (default state_dir/logs) | JSON Lines, one record per line; rotated to orquelo.1.jsonl, orquelo.2.jsonl, ... | agents and tools: orquelo logs, jq, grep |
stderr of orquelo serve | short text | people watching a terminal |
log:
level: info # debug | info | warn | error; serve -debug sets debug
dir: logs # relative to the configuration file
max_mb: 20 # rotate at this size
keep: 5 # rotated files kept2. What a Record Looks Like
{"time":"2026-11-13T16:18:41.808-08:00","level":"INFO","msg":"model.called",
"src":"internal/host/engine/caller.go:62","pid":16470,
"run_id":"run_2949231e3d0282a25ad6","connection":"console","conversation_id":"console","runtime":"agent",
"model":"openai","instance":"agent","dur_ms":4699,"tokens_in":1238,"tokens_out":89,"finish":"tool_calls"}- ◆
msgis a stable event name,area.what, unique in the code base. Searching the code for"model.called"finds the one line that writes it;srcgives the file and line directly. - ◆Keys come from one vocabulary (
pkg/logging/keys.go):run_id,connection,conversation_id,event_id,instance,plugin,tool,call_key,model,delivery_id,question_id,dur_ms,err,err_code, and so on. A search forrun_id=Xfinds every line about run X. - ◆Errors are
err(text) pluserr_code(the stableplugin.Errorcode, e.g.llm.rate_limited,feishu.230002).erris absent on success, so filtering onerrfinds failures only. - ◆Correlation comes from the context. The Host binds identities to the context once, and every record logged under it carries them:
| Bound at | Keys |
|---|---|
| an inbound event being routed | connection, event_id, conversation_id |
| a run (start, recovery, finish) | run_id, connection, conversation_id, runtime |
| a tool call | tool, call_key |
| a question | question_id |
| a delivery | delivery_id, run_id, connection, conversation_id |
| a plugin instance's logger | instance, plugin |
A process plugin logs JSON to its stderr through the same package (pkg/plugin/serve sets this up, with the call's run_id); the Host forwards each record with its own event name and src, adding the instance.
3. How an Agent Investigates
- A user reports a failure. Failure messages end with the run id, e.g.
Sorry, something went wrong: ... (ref run_2949...). orquelo logs -c CONFIG -run run_2949...prints the run's timeline:run.created,run.started, eachmodel.calledandtool.calledwith durations,question.asked/question.settled,delivery.sent,run.finishedwithstate,err,err_code.- Without an id:
orquelo logs -c CONFIG -level warn -since 1h, or-event delivery.for one area, or-attr delivery_id=....-jsonprints raw lines forjq. srcpoints at the code; the event name finds it with a search. The firsthost.startedrecord of a process gives the version, commit, platform, configuration revision and paths.- Provider failures carry the provider's id for their support:
request_idfrom model APIs,log_idin Feishu error messages.
4. What Is Logged
| Area | Events |
|---|---|
| Host lifecycle | host.started, host.stopped, config.reloaded, control.handled |
| Plugins | plugin.unavailable, plugin.requirement_unavailable, process.started, process.exited, process.start_failed, process.stderr, sdk.output |
| Routing | route.decided (action, trigger, user), route.failed, run.created |
| Runs | run.started, run.finished (warn when failed, with dur_ms), run.requeued, run.panicked |
| Models and tools | model.called, tool.called, tool.refused (reason: not_found, changed, call_chain, policy, reviewer, not_approved), tool.outcome_unknown, tool.replayed (debug) |
| People | question.asked, question.settled, approval.reviewer_decided |
| Delivery | delivery.sent, delivery.retry_scheduled, delivery.failed_permanently |
| Agent Runtime | agent.step (debug), agent.step_limit, agent.completion_retry, agent.output_cutoff, agent.content_filtered |
| Providers | llm.response (debug), llm.http_error, llm.network_error, llm.retry (every model plugin that uses pkg/modelhttp; the line's plugin names it), modelfiles.uploaded, modelfiles.deleted, modelfiles.abandoned (error), feishu.message_received, feishu.message_dropped |
5. Safety
- ◆Values of keys that name secrets (
*secret*,*password*,*api_key*,authorization,cookie,*access_token*,token) are written as[redacted]. - ◆String values are cut at 4 KiB with a marker of how much was cut.
- ◆Third-party libraries log through
logging.SDK, which removes URL query strings (connection URLs carry tickets). - ◆Message text and tool arguments are not logged at info. Ids and counts are logged instead; debug may add more.
6. Rules for Code
These rules are in AGENTS.md section 12 and checked by TestLogConventions in pkg/logging, which make check runs:
- ◆Only
pkg/loggingimportslog/slog; nothing importslog. Components receive a*logging.Logger; a nil logger drops everything. - ◆Every call is
log.Info(ctx, "area.what", key, value, ...)(orDebug,Warn,Error,Log): the event is a string literal, unique in the repository; keys are literals orlogging.Key*constants from the vocabulary. - ◆Never log secrets, message text or tool arguments at info (section 5).
- ◆New boundary code logs its outcome: one record per external call (with
dur_ms, anderron failure), one per state transition, and one per refusal with a stablereason.