Skip to content

feat: wake a chat when a watched background process exits - #263

Merged
ibetitsmike merged 9 commits into
mainfrom
mike/chat-process-wakeups-1-exit
Nov 13, 2026
Merged

ibetitsmike merged 9 commits into
mainfrom
mike/chat-process-wakeups-1-exit

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Part of #248

wait_for_events takes process_ids, the background_process_id values that execute returns. The chat gets one message per process when it exits, with its exit code and the last 40 lines (at most 4 KB) of its output.

  • The tool checks each ID with one ProcessOutput call on the chat's workspace agent and refuses IDs the agent does not know for this chat, IDs an active wake-up already watches, empty IDs, and more than 10 IDs.
  • The wake-up worker stores one process_exit event per process (process ID, command, agent ID) in chat_wakeups.events, so the watch survives a coderd restart. Each tick it reads the workspace's latest build once and dials each agent once.
  • A watch on a process that already exited wakes the chat on the first poll after the turn ends.
  • The chat gets a lost-watch message instead of an exit when the workspace's latest build is not a start or no longer has the agent (no dial), or when the agent answers 404 (agent restarted, or the process exited more than an hour ago).
  • A failed read logs a warning and retries after 1 minute. A pending pull request entry keeps its own 1-minute interval.
  • codersdk.ChatWakeupEvent gains process_id and command. The apidoc, schemas.md and typesGenerated.ts are regenerated.
  • ARCHITECTURE.md gets one TODO for Mike.

Output-pattern wake-ups (pattern, cool-down, maximum events) and the UI follow in later PRs.

Xum opened this PR on behalf of @ibetitsmike.

wait_for_events takes process_ids: background processes that execute
started for this chat. The wake-up worker polls the chat's workspace
agent once per tick with ProcessOutput and sends one message per process
when it exits, with its exit code and the end of its output, or a
lost-watch message when the workspace stopped or was rebuilt or the
agent no longer knows the process. A failed read retries after a minute.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T01:59:56.217290Z 63e228f Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44d8c04b3b

ℹ️ 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".

Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/fork_wait_for_events.go Resolved
Comment thread coderd/x/chatd/fork_wait_for_events.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum posted this on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 48f998c145

ℹ️ 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".

Comment thread coderd/x/chatd/fork_process_events.go Resolved
Comment thread coderd/x/chatd/fork_wait_for_events.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum posted this on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bbc21eee57

ℹ️ 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".

Comment thread coderd/x/chatd/fork_process_events.go Resolved
Comment thread coderd/x/chatd/fork_process_events.go Resolved
Comment thread coderd/x/chatd/fork_wait_for_events.go Resolved
Comment thread codersdk/fork_chat_wakeups.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum posted this on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 31a872fedc

ℹ️ 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".

Comment thread coderd/x/chatd/fork_process_events.go Resolved
Comment thread coderd/x/chatd/fork_process_events.go Resolved
Comment thread coderd/x/chatd/fork_process_events.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum posted this on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 63e228f858

ℹ️ 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".

@ibetitsmike
ibetitsmike merged commit addead5 into main Nov 13, 2026
9 checks passed
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum merged this PR on behalf of @ibetitsmike.

Merge evidence for head 63e228f858:

  • fork-ci run 43348497112 succeeded on this head, and all 9 check runs succeeded.
  • Codex reviewed 63e228f858 and found no major issues. No review threads are unresolved. One P2, the site status pill, is deferred to PR 3.
  • W15 ran the Go tests in the Fork ops lane, with negative controls for each fix.
  • W15 ran UAT in loopback containers with a real chat on the oMLX model, and 5 of 5 cases passed on this head:
    • a process exit wakes the chat with the exit code and output tail;
    • watching a process that already exited wakes the chat at once;
    • the wake survives a coderd restart mid-watch;
    • an agent restart and a workspace stop each produce a lost-watch message.
  • Fork ops checked the UAT and the teardown. The throwaway oMLX key gets 401.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant