Skip to content

🤖 feat: add bash monitor wake events#3268

Open
ammar-agent wants to merge 6 commits into
mainfrom
monitor-yd0j
Open

🤖 feat: add bash monitor wake events#3268
ammar-agent wants to merge 6 commits into
mainfrom
monitor-yd0j

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

Summary

Adds Claude-Code-style wake-on-match monitoring to background bash commands. A background bash can now include a monitor block with a regex filter; matching output lines are coalesced and delivered to the agent as synthetic queued wake messages while the existing task_await harvest path continues to work.

Background

Long-running dev servers, watch tests, and log tails previously required polling with task_await to notice important output. This change lets the process itself wake the agent when relevant output appears, without introducing a new tool family or task-ID namespace.

Implementation

  • Extends the bash tool schema/result with an optional monitor block for background commands.
  • Adds a write-time monitor tail loop in BackgroundProcessManager with independent cursors, cooldown coalescing, match caps, dropped-line accounting, and cleanup on process termination.
  • Emits renderer-only monitor-match events while waking the model through AgentSession.queueMessage(..., { synthetic: true, agentInitiated: true }).
  • Surfaces monitor counters/last matches in background process API/store/UI plumbing.
  • Updates generated tool docs and built-in skill content.

Validation

  • bun test src/node/services/backgroundProcessManager.test.ts src/node/services/tools/bash.test.ts
  • make static-check

Risks

This touches background process lifecycle and queued-message wake plumbing. The implementation keeps monitors optional, preserves existing bash:<id> task behavior, and stops only the monitor—not the process—when max_events is reached.


Generated with mux • Model: openai:gpt-5.5 • Thinking: xhigh • Cost: 2255777{MUX_COSTS_USD:-unknown}

@mintlify
Copy link
Copy Markdown

mintlify Bot commented May 12, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
Mux 🟢 Ready View Preview May 12, 2026, 3:58 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

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

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: c8cd548974

ℹ️ 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 src/common/utils/tools/toolDefinitions.ts
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review
Please take another look.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review
Please take another look after the CI fix.

Copy link
Copy Markdown

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

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: ab9f39bd6d

ℹ️ 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 src/node/services/agentSession.ts Outdated
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review
Please take another look after the monitor wake send-options fix.

Copy link
Copy Markdown

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

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: f77ed9055e

ℹ️ 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 src/node/services/backgroundProcessManager.ts Outdated
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review
Please take another look after bounding incomplete monitor buffers.

Copy link
Copy Markdown

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

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: 564013ae0b

ℹ️ 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 src/node/services/agentSession.ts
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review
Please take another look after coalescing queued monitor wakes.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

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

Add an optional bash monitor block for background processes that tails output with a regex, coalesces matching lines, and wakes the agent with a synthetic queued message. Surface monitor state in background process APIs/UI and keep task_await/task_list/task_terminate on the existing bash task IDs.

Validation:
- bun test src/node/services/backgroundProcessManager.test.ts src/node/services/tools/bash.test.ts
- make static-check

---

_Generated with `mux` • Model: `openai:gpt-5.5` • Thinking: `xhigh` • Cost: `2245854{MUX_COSTS_USD:-unknown}`_

<!-- mux-attribution: model=openai:gpt-5.5 thinking=xhigh costs=28.24 -->
Allow nullable omitted monitor options in the bash tool schema so strict-mode providers can pass null for optional values while the tool handler continues applying runtime defaults.

Validation:
- make fmt
- bun test src/node/services/backgroundProcessManager.test.ts src/node/services/tools/bash.test.ts
- make static-check

---

_Generated with `mux` • Model: `openai:gpt-5.5` • Thinking: `xhigh` • Cost: `2417461{MUX_COSTS_USD:-unknown}`_

<!-- mux-attribution: model=openai:gpt-5.5 thinking=xhigh costs=28.24 -->
Guard monitor-match subscription setup so AgentSession remains resilient when tests or startup-time doubles do not expose EventEmitter methods.

Validation:
- bun test src/node/services/agentSession.disposeRace.test.ts
- bun test src/node/services/agentSession*.test.ts
- bun test src/node/services/backgroundProcessManager.test.ts src/node/services/tools/bash.test.ts
- bun test src/browser/stores/GitStatusStore.test.ts
- make static-check

Note: a full local `make test` run reproduced the CI AgentSession failure fix, then exposed an unrelated local-only GitStatusStore window-listener issue; the GitStatusStore file passes in isolation.

---

_Generated with `mux` • Model: `openai:gpt-5.5` • Thinking: `xhigh` • Cost: `2739104{MUX_COSTS_USD:-unknown}`_

<!-- mux-attribution: model=openai:gpt-5.5 thinking=xhigh costs=28.24 -->
Reuse the latest normalized send options when queuing synthetic monitor wake turns so sendQueuedMessages can start the follow-up agent turn with a model and agent context.

Validation:
- bun test src/node/services/agentSession.disposeRace.test.ts
- bun test src/node/services/agentSession*.test.ts
- bun test src/node/services/backgroundProcessManager.test.ts src/node/services/tools/bash.test.ts
- make static-check

---

_Generated with `mux` • Model: `openai:gpt-5.5` • Thinking: `xhigh` • Cost: `2921293{MUX_COSTS_USD:-unknown}`_

<!-- mux-attribution: model=openai:gpt-5.5 thinking=xhigh costs=28.24 -->
Cap retained incomplete monitor lines to the bash line-byte limit so newline-free output from progress bars or long log records cannot grow memory unbounded while waiting for a line terminator.

Validation:
- bun test src/node/services/backgroundProcessManager.test.ts
- bun test src/node/services/agentSession.disposeRace.test.ts
- bun test src/node/services/backgroundProcessManager.test.ts src/node/services/tools/bash.test.ts
- make static-check

---

_Generated with `mux` • Model: `openai:gpt-5.5` • Thinking: `xhigh` • Cost: `3070966{MUX_COSTS_USD:-unknown}`_

<!-- mux-attribution: model=openai:gpt-5.5 thinking=xhigh costs=28.24 -->
Track monitor wake task IDs already queued for a busy session so repeated matches from the same background process do not append unbounded synthetic prompts before the agent can react.

Validation:
- bun test src/node/services/agentSession.disposeRace.test.ts
- bun test src/node/services/agentSession*.test.ts
- bun test src/node/services/backgroundProcessManager.test.ts src/node/services/tools/bash.test.ts
- make static-check

---

_Generated with `mux` • Model: `openai:gpt-5.5` • Thinking: `xhigh` • Cost: `3289765{MUX_COSTS_USD:-unknown}`_

<!-- mux-attribution: model=openai:gpt-5.5 thinking=xhigh costs=28.24 -->
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