Repository navigation
feat(daemon): centralize daemon, worker, channel and connection logs - #1424
Merged
Merged
Conversation
Started children (session workers, scheduled fires, heartbeat runs) log JSON to stderr and keep no log file of their own. The daemon collects their stderr into the daemon log with project_dir, conversation_id and worker_pid tags, logs client connects and disconnects with client and protocol_version, logs the extension attach and detach with extension_version, and tags routing errors and channel threads with project_dir and conversation_id. The daemon docs name the log location.
This was referenced Sep 30, 2026
edenreich
marked this pull request as ready for review
September 30, 2026 10:41
A child log line at fatal or panic level ended the daemon, because the collector re-logged it at the child's own level. The level now stops at error. The collector no longer adds its own caller and stacktrace to a collected line. They duplicated the child's keys and the collector's stacktrace shadowed the real one. The stderr JSON flag is read once and cleared, so the processes a worker starts through its Bash tool keep their own log files and stop writing JSON logs into the tool output. agentrunner collects a run's stderr as it runs, tagged with project_dir, conversation_id and worker_pid. Job runs keep their real timestamps and survive a daemon stop mid-run. Result.Stderr holds only the last plain line, so a failed run's stored error is the run's own error again and not its whole log stream. The worker's stderr pipe is closed after collection. The scheduler's daemon-side lines and the remaining telegram thread lines carry conversation_id. The binding logs protocol_version the same way on connect and disconnect.
Contributor
|
🎉 This PR is included in version 0.219.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1402
Centralizes daemon, worker, channel and connection logs: the daemon owns one tagged log stream and the processes it starts keep no log file of their own.
Summary
Session workers and one-shot job runs (scheduled fires, heartbeat ticks) now log JSON to stderr only and create no
app-<date>.logof their own. The daemon collects their stderr into~/.infer/logs/daemon-<date>.logas they run, with every line taggedproject_dir,conversation_id(the AG-UIthreadId) andworker_pid, so one request crossing daemon, worker and client leaves one trail. Client connect and disconnect and the browser extension's attach and detach are logged on that path too, and routing errors carry the thread tags when the frame reached one.A [DOCS] ticket in inference-gateway/docs (issue 872) tracks the mirrored daemon docs. Streaming logs to clients over the binding stays out of scope per the issue.
Changes
internal/platform/logger:ChildStderrJSONEnv(INFER_LOG_STDERR_JSON) makes a child process log JSON to stderr and skip its log file. The flag is read once and cleared, so it reaches the direct child only and the processes a worker starts through its Bash tool keep their own log filesinternal/platform/logger:CollectChildStderrmerges a child's JSON stderr lines into the host's log (child keeps msg, fields and level, raw lines log as-is) enriched with the collector tags. The level stops at error, since re-logging a fatal or panic line would end the daemon. The collector adds no caller or stacktrace of its own, so the child's stay readable. It returns the last plain line, the child's own errorinternal/sessions/infrastructure.LaunchWorker: sets the child env flag, pipes the worker's stderr throughCollectChildStderrwithproject_dir,conversation_idandworker_pid(wascmd.Stderr = os.Stderr), closes the pipe after collection, and tags the worker-exit warning withworker_pidinternal/platform/agentrunner:Runsets the child env flag and collects the run's stderr as it runs, taggedproject_dir,conversation_idandworker_pid.Result.Stderrholds only the last plain line, so a failed run's stored error (run.Error,job.LastError) stays the run's own error and not its whole log streaminternal/scheduler(cron fires) andscheduler/heartbeat(ticks): their daemon-side lines useconversation_idin place ofsession_idinternal/protocols/agui: aConnanswersHelloAttrwith the other fields its hello declared (minus the token). The binding logs client connects and disconnects withclientandprotocol_versioninternal/browser/infrastructure.ExtensionRelay: logs the extension attaching and detaching withextension_version(read from the hello, which the binding never named), and warns when a browser command has no extension to route throughinternal/sessions.Registry:routereturns the thread, so routing failures (unknown thread, launch failure, send to a dead worker) log withproject_dirandconversation_id. A failed worker browser command is logged with the thread's tagsinternal/presentation/telegram: the channel's message routing, render delivery, dropped frames and interrupt answers log withproject_dirandconversation_idalongsidesender_iddocs/commands-reference.mdsays where the daemon log lives. Sessions and agui READMEs updatedVerification
go test ./...(puregotag) passes, and the touched packages pass under-racetask precommit:runpassesagentrunner.Runreturns only the last plain stderr line, and the hello token is not readable throughHelloAttr