fix(runner): restore caller stdout instead of raw sys.__stdout__#82
Merged
fix(runner): restore caller stdout instead of raw sys.__stdout__#82
Conversation
When log_file_path is set, runner.run() replaced sys.stdout with its own _Tee. The finally block restored sys.stdout = sys.__stdout__ (the raw original), which destroyed any outer tee the caller had installed (e.g. a workflow-level tee that logs all output to a file). Fix: save sys.stdout before the verb runs and restore to that instead of sys.__stdout__, so any outer tee survives across verb calls. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes Agent.run()’s stdout restoration when log_file_path is enabled so Orbit doesn’t clobber a caller-provided sys.stdout (e.g., a workflow-level tee/capture) after the run completes.
Changes:
- Capture the caller’s current
sys.stdoutbefore installing Orbit’s_Tee. - Restore
sys.stdoutback to the captured value in thefinallyblock (instead ofsys.__stdout__) when closing the log file.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem
When
log_file_pathis set on a verb,runner.run()installs its own_Teeoversys.stdout. Thefinallyblock then restores with:sys.__stdout__is the raw original stdout — not whatever the caller had installed. If the caller had replacedsys.stdoutwith their own tee (e.g. a workflow runner that logs all output to a file), this line silently destroys it. Everyprint()call after the verb returns goes to the void.Symptom
In a workflow that tees
sys.stdoutto a log file and runs multiple orbit verbs in sequence, the log file is truncated after the first verb's completion banner. All subsequent node labels, status checks, and error tracebacks are swallowed silently. The run showsstatus=errorin the DB with no visible cause.Fix
Save
sys.stdoutbefore touching it, restore to that:Two-line change, no behaviour change when
log_file_pathis not set.🤖 Generated with Claude Code