Skip to content

Fix MCP lifecycle trace user scope - #1646

Merged
henrypark133 merged 7 commits into
stagingfrom
codex/fix-ci-test-hangs
Mar 25, 2026
Merged

henrypark133 merged 7 commits into
stagingfrom
codex/fix-ci-test-hangs

Conversation

@henrypark133

Copy link
Copy Markdown
Collaborator

Summary
Fix the advanced MCP lifecycle trace test to use a single user scope throughout install, token injection, and activation.

Root cause
The test rig runs tool_install as test-user, but the test was injecting the OAuth token and calling activate() under default. That split the MCP install and activation steps across different user namespaces, so activation correctly returned NotInstalled.

Change

  • add a TEST_USER_ID constant in tests/e2e_advanced_traces.rs
  • use that same user id when creating the MCP token secret
  • use that same user id when calling activate(mock-notion, ...)

Verification

  • cargo fmt --all -- --check
  • local targeted cargo test for advanced::mcp_extension_lifecycle was blocked by local disk exhaustion during link: No space left on device
  • authoritative verification should come from CI on this PR

Notes
This is a test-only fix; no product behavior changes.

Copilot AI review requested due to automatic review settings March 25, 2026 19:54
@github-actions github-actions Bot added scope: agent Agent core (agent loop, router, scheduler) scope: ci CI/CD workflows size: L 200-499 changed lines risk: medium Business logic, config, or moderate-risk modules contributor: core 20+ merged PRs labels Mar 25, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily addresses a bug in the advanced MCP lifecycle trace test, ensuring that the test uses a consistent user scope for all steps of the extension lifecycle. This resolves an issue where the test failed due to a mismatch in user contexts. Additionally, it introduces a new "single-message REPL mode" feature, which allows the agent to handle a single user input and then terminate, with robust handling for event-triggered routines to ensure they complete before exit.

Highlights

  • MCP Lifecycle Trace Fix: Corrected the advanced MCP lifecycle trace test to ensure consistent user scope (test-user) across installation, token injection, and activation, resolving a NotInstalled error caused by user context mismatch.
  • Single-Message REPL Mode: Introduced a new single_message_mode for the REPL channel, allowing the agent to process a single user input and then gracefully exit. This includes waiting for event-triggered routines to complete before termination.
  • Enhanced Event Trigger Handling: Improved the routine engine to support waiting for event-triggered routines to finish in single-message REPL mode, preventing premature process termination and ensuring all background tasks complete.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/test.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@github-actions github-actions Bot added size: XS < 10 changed lines (excluding docs) risk: low Changes to docs, tests, or low-risk modules and removed size: L 200-499 changed lines risk: medium Business logic, config, or moderate-risk modules labels Mar 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a single-message REPL mode, which modifies how event-triggered routines are handled by waiting for their completion before the REPL session exits. This involves changes to message processing, routine engine execution, and REPL channel management. The review comments suggest updating the pull request description to accurately reflect the full scope of these product behavior changes, as it was initially described as a 'test-only fix'. Additionally, an idiomatic improvement in routine_engine.rs is suggested, recommending let _ = ... instead of std::mem::drop(...) for ignoring JoinHandle return values.

I am having trouble creating individual review comments. Click here to see my feedback.

src/agent/agent_loop.rs (88-95)

high

The PR description states this is a 'test-only fix', but this function is part of a larger set of changes to the single-message REPL mode and routine engine, which are product behavior changes. To maintain clarity for future code maintenance, please update the pull request title and description to accurately reflect the full scope of the changes, including the improvements to the single-message REPL mode.

src/agent/routine_engine.rs (214)

medium

Using std::mem::drop to ignore the JoinHandle is a bit unconventional. The handle is dropped at the end of the statement anyway, so this call is redundant. To explicitly ignore the return value and avoid compiler warnings about an unused result, it's more idiomatic to assign it to _.

            let _ = self.spawn_fire(triggered.routine, "event", Some(triggered.detail));

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR primarily fixes the advanced MCP lifecycle trace E2E test by ensuring MCP install, token injection, and activation all occur under the same user scope. It also includes additional changes to REPL single-message mode behavior, routine-engine trigger execution semantics, and CI test timeouts.

Changes:

  • Fix mcp_extension_lifecycle E2E trace test to consistently use "test-user" for secret injection and activation.
  • Update REPL -m (single-message) mode to delay quitting until the turn finishes, including waiting for event-triggered routines.
  • Add explicit timeouts around CI test commands and update a Telegram hot-activation E2E assertion payload shape.

Reviewed changes

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/e2e_advanced_traces.rs Uses a single TEST_USER_ID for MCP token injection and activation in the lifecycle trace test.
tests/e2e/scenarios/test_telegram_hot_activation.py Updates expected setup payloads to include an empty fields object.
src/channels/repl.rs Changes single-message REPL mode to enqueue /quit only after the turn finishes; adds metadata flagging for single-message mode.
src/agent/routine_engine.rs Refactors event trigger matching to optionally await spawned routine tasks; changes spawn_fire to return a JoinHandle.
src/agent/agent_loop.rs Detects single-message REPL via message metadata and adjusts shutdown/response suppression behavior accordingly.
.github/workflows/test.yml Adds job-level timeouts and wraps cargo test invocations with timeout to bound runtime.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@henrypark133
henrypark133 merged commit c949521 into staging Mar 25, 2026
14 checks passed
@henrypark133
henrypark133 deleted the codex/fix-ci-test-hangs branch March 25, 2026 20:17
@claude

claude Bot commented Mar 25, 2026

Copy link
Copy Markdown

No issues found.

bkutasi pushed a commit to bkutasi/ironclaw that referenced this pull request Mar 28, 2026
* Fix REPL single-message hang and cap CI test duration

* Fix Clippy nested-if lint in REPL startup

* Fix single-message approval flow

* Handle empty single-message REPL exits

* Wait for one-shot event routines before exit

* Fix MCP lifecycle trace user scope
drchirag1991 pushed a commit to drchirag1991/ironclaw that referenced this pull request Apr 8, 2026
* Fix REPL single-message hang and cap CI test duration

* Fix Clippy nested-if lint in REPL startup

* Fix single-message approval flow

* Handle empty single-message REPL exits

* Wait for one-shot event routines before exit

* Fix MCP lifecycle trace user scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: low Changes to docs, tests, or low-risk modules scope: agent Agent core (agent loop, router, scheduler) scope: ci CI/CD workflows size: XS < 10 changed lines (excluding docs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants