feat(logs): fetch execution log output and fix background runs#412
Merged
Conversation
get_execution_logs and `flow logs` now return captured output, not just metadata. New tail/grep/content options slice the log, keeping the end where failures surface; output is byte-capped (server-side for MCP) so a large log can't flood an agent's context. Reading is live, so it works on still-running executions — a running record now resolves its log file by archive ID (the resolved path is only written on completion). Also fixes `flow exec --background`, which silently ran inline for --cmd and --spec and dropped flags for named executables. The detached child is now rebuilt from the full arg list (minus the background flag), so all run modes background identically. A nameless --spec falls back to a spec-<label> ref instead of an empty "verb ws/". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Summary
Three related changes to execution logs and background runs, driven by an agent's-eye view of the
get_execution_logsMCP tool.1. Fetch log output, not just metadata (+ truncation)
get_execution_logs/flow logspreviously returned only run metadata (ref, status, exitCode, error) and alogFilepath — never the captured output. Now:tail,grep,content(andmax_bytes) options slice a run's output, each keeping the end of the log where failures surface.contentTruncated/contentTotalLines/contentReturnedLinesso the caller always knows it's seeing a slice.Default behavior is unchanged: with no content option, only metadata is returned, so listing stays cheap.
2. Fix
flow exec --background--backgroundsilently ran inline for--cmdand--spec(the ad-hoc/spec dispatch returned before the background check), and even on the named pathlaunchBackgroundrebuilt the child from justverb + args, dropping every flag. Now the detached child is reconstructed from the full arg list with only the background flag stripped, so named /--cmd/--specruns all background identically and every flag propagates.--spec -(stdin) +--backgroundis rejected with a clear message (a detached child has no stdin to re-read).3. Nameless
--specref fallbackA
--specwithout aname:produced an empty ref (exec flow/). It now falls back tospec-<slugified-label>(orspec), mirroring--cmd'sadhoc-naming, so history and the background-run line show a meaningful ref.Testing
flow validatepasses locally: generate → lint → unit + e2e tests → schema validation.ExtractContentslicing (tail/grep/byte-cap/boundaries), in-progress join-by-ID,backgroundChildArgs,transientSpecName, plus MCP handler arg-forwarding/cap-clamping cases.--backgrounddetaching for--cmd/--spec, and the spec-name fallback.🤖 Generated with Claude Code