Add steerable second opinion task manager - #17
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efa6f52978
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| prompt = build_followup_prompt(job, clean_message) | ||
| cmd = command_for_agent(agent, cwd=cwd, mode=mode, prompt=prompt, model=model, trust=trust) |
There was a problem hiding this comment.
Build queued prompts only when their turn begins
When a steering message is sent during an active turn, this snapshots the log immediately, so the queued command permanently contains only partial output (or no output) from the active turn. Once that turn finishes, the follow-up therefore runs without the result it is supposed to continue from; multiple queued messages similarly cannot see earlier queued turns. Build the follow-up prompt and command when the worker claims the turn rather than when the message is enqueued.
Useful? React with 👍 / 👎.
| updated = update_job(job_id, append_turn) | ||
| if job_status(updated) != "running": | ||
| spawn_job_worker(job_id) |
There was a problem hiding this comment.
Claim worker ownership atomically before spawning
If two manager processes enqueue messages for the same idle job concurrently, both can finish update_job with a non-running snapshot before either calls spawn_job_worker, causing two workers to be launched. Those workers can claim separate queued turns and run their provider commands concurrently in the same workspace, or even race over the same turn, defeating the promised serialized steering workflow. The running check and worker reservation need to occur as one locked state transition.
Useful? React with 👍 / 👎.
What changed
Why
Second Opinion background jobs were previously visible only through
jobsandwait. This makes agent-spawned tasks directly observable and steerable without embedding into or modifying the coding-agent applications.The native manager is optional but opens by default for background tasks. Users can choose
--manager terminal,--manager none,--no-window, or setSECOND_OPINION_MANAGERglobally.Validation
ruff check bin/second-opinion testspython3 -m unittest discover -s tests -v(24 tests)python3 -m py_compile bin/second-opinionbash -n install.sh