chore(agent): log SDK options and capture claude subprocess stderr#16
Merged
Conversation
Surface the exact configuration archy passes to the partio-io SDK (model, cwd, MCP servers, skills dirs) and capture the subprocess's stderr so we can see what claude actually says when it exits without consulting the model. Uses the SDK's WithStderrCallback option (callback fires from the SDK's drain goroutine, guarded by a mutex). Adds RunResult.SubprocessStderr; surfaces it in verification-failure errors via cmd/daily_run.go. Plain stderr output for now; structured logging is a separate concern. Tests get io.Discard for the invocation log to keep output quiet.
5 tasks
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
./archy daily --forcewas reporting a successful agent run withturns=0, zero cost, zero tool calls, empty text, duration 1.6s — meaning theclaudesubprocess was exiting immediately without consulting the model. The actual error was on the subprocess's stderr, which archy was dropping. This PR makes that stderr visible.SDK investigation: the partio-io SDK exposes
claude.WithStderrCallback(func(string)) Option(option.go:225). Option A from the spec applied directly — no need to fall back.Changes:
RunResult.SubprocessStderrfield.Runregisters aWithStderrCallbackthat appends each line into a mutex-guarded buffer (callback fires on the SDK's drain goroutine), and writes the buffer intoRunResult.SubprocessStderron every return path. The iteration-error path also includes stderr inline in theErrRunerror string.logSDKInvocationhelper prints a structured one-time summary of the agent setup to stderr (skill, model, max_turns, permission_mode, cwd, cli_path, archy_binary, sdk_option_count, enabled MCP servers, skills dirs). No secrets are logged.Runtime.stderrLog io.Writerfield defaults toos.Stderr; tests swap inio.Discardto keep output quiet.cmd/daily_run.go:explainAgentOutcomesurfacesSubprocessStderr(truncated to 2000 chars) in the verification-failure error.No logging framework,
--debugflag, or trace file. Plain stderr output for now.Test plan
go build ./...go test -race ./...(14 packages green)go vet ./...golangci-lint run(0 issues)TestRunDaily_VerificationErrorIncludesSubprocessStderr./archy daily --force— the invocation summary prints first; on verification failure the error includesclaude stderr: <whatever>so we can finally see why the subprocess exits