Skip to content

fix(agents): refresh daemon provider configuration - #271

Open
Waishnav wants to merge 1 commit into
codex/provider-launch-configfrom
codex/agent-daemon-config-revision
Open

fix(agents): refresh daemon provider configuration#271
Waishnav wants to merge 1 commit into
codex/provider-launch-configfrom
codex/agent-daemon-config-revision

Conversation

@Waishnav

@Waishnav Waishnav commented Aug 31, 2026

Copy link
Copy Markdown
Owner

A running daemon previously kept the provider configuration it loaded at startup even after config.jsonc changed. The client and daemon now compare an internal stable revision during their private handshake without returning or logging the revision itself.

A stale idle daemon is stopped and replaced before new work starts. A stale daemon with active work is left alone and returns retryable DAEMON_CONFIG_CHANGED until that work finishes. The public daemon status shape stays unchanged, and the protocol upgrade path still handles older idle daemons safely. Tests cover stable hashing, idle replacement, active-work preservation, version skew, and hidden status fields; the full suite and production build pass.

Summary by CodeRabbit

  • New Features

    • Local agent configuration changes are now detected automatically.
    • Idle agent processes are refreshed when their configuration is outdated.
    • Active operations receive a clear configuration-changed error instead of continuing with stale settings.
    • Configuration comparisons remain consistent regardless of provider or environment variable ordering.
  • Bug Fixes

    • Improved handling of configuration changes occurring while an agent is starting or processing a request.
    • Added safer idle shutdown behavior to avoid interrupting active work.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 14e7c9a8-27da-4572-9849-af6261decd18

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f793cf0-fb45-4c0c-984a-9dfd687f40b0

📥 Commits

Reviewing files that changed from the base of the PR and between 9bee905 and 46a8a38.

📒 Files selected for processing (11)
  • src/cli.test.ts
  • src/local-agent-client.ts
  • src/local-agent-config.test.ts
  • src/local-agent-config.ts
  • src/local-agent-daemon-lifecycle.ts
  • src/local-agent-daemon-main.ts
  • src/local-agent-daemon-protocol.test.ts
  • src/local-agent-daemon-protocol.ts
  • src/local-agent-daemon.test.ts
  • src/local-agent-daemon.ts
  • src/local-agent-errors.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The change adds deterministic provider configuration revisions to local agent clients and daemons. The daemon protocol reports configuration matches and supports conditional stops. Clients replace stale idle daemons and report active stale daemons with DAEMON_CONFIG_CHANGED.

Changes

Local agent configuration synchronization

Layer / File(s) Summary
Configuration revision generation and wiring
src/local-agent-config.ts, src/local-agent-config.test.ts, src/local-agent-client.ts, src/local-agent-daemon-main.ts
The code generates a deterministic SHA-256 revision from normalized provider settings. Clients and daemons receive the revision from subagents configuration.
Daemon protocol and active-turn protection
src/local-agent-daemon-protocol.ts, src/local-agent-daemon.ts, src/local-agent-daemon-lifecycle.ts, src/local-agent-daemon-protocol.test.ts
The protocol adds revision-aware hello responses and conditional daemon.stop parameters. The daemon tracks active turns and rejects idle-only stops during active work.
Stale daemon replacement and error handling
src/local-agent-client.ts, src/local-agent-errors.ts, src/local-agent-daemon.test.ts, src/cli.test.ts
The client detects mismatched revisions, stops stale idle daemons, and returns DAEMON_CONFIG_CHANGED for active daemons. Tests cover replacement, races, protocol responses, and error conversion.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 46a8a

This change refreshes daemon provider configuration while preserving active work and protocol compatibility; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant LocalAgentClient
  participant LocalAgentDaemon
  participant Manager
  LocalAgentClient->>LocalAgentDaemon: Send hello with configRevision
  LocalAgentDaemon-->>LocalAgentClient: Return status and configMatches
  alt Configuration matches
    LocalAgentClient->>LocalAgentDaemon: Start or continue turn
    LocalAgentDaemon->>Manager: Execute tracked turn
    Manager-->>LocalAgentDaemon: Return turn result
    LocalAgentDaemon-->>LocalAgentClient: Return turn result
  else Configuration differs
    LocalAgentClient->>LocalAgentDaemon: Request daemon.stop with ifIdle
    LocalAgentDaemon->>Manager: Check active work
    LocalAgentDaemon-->>LocalAgentClient: Stop idle daemon or return DAEMON_CONFIG_CHANGED
  end
Loading

Poem

I’m a rabbit with revisions to track,

Hashing each provider, front to back.
Idle daemons stop when configs stray,
Busy turns keep mismatches at bay.
Protocol flags guide the way!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: refreshing daemon provider configuration when the configuration changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/agent-daemon-config-revision

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds stable provider-configuration revisions to the private daemon handshake and safely replaces stale idle daemons while preserving active work.

  • Computes deterministic revisions from persisted provider configuration.
  • Adds revision matching to the upgraded daemon protocol.
  • Uses an atomic idle-only stop operation to prevent replacement from interrupting turns.
  • Preserves the public daemon status shape and legacy protocol replacement path.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported replacement race is closed by atomic request admission and active-work checks, and the configuration-revision concern was withdrawn after clarification of the intended persisted-configuration boundary.

Important Files Changed

Filename Overview
src/local-agent-client.ts Adds revision-aware hello handling, stale-daemon replacement, and atomic idle-only stopping while retaining legacy upgrade behavior.
src/local-agent-daemon.ts Returns private revision-match state and coordinates conditional shutdown with in-flight and active-turn accounting.
src/local-agent-daemon-protocol.ts Upgrades hello and stop request shapes and adds strict decoding for the private handshake response.
src/local-agent-config.ts Computes a deterministic SHA-256 revision over normalized persisted provider configuration.
src/local-agent-daemon.test.ts Covers stale idle replacement, active-work preservation, the turn-start race, protocol upgrades, and status-field privacy.

Sequence Diagram

sequenceDiagram
    participant C as Client
    participant D as Running daemon
    participant M as Agent manager
    C->>D: hello(configRevision)
    D-->>C: status + configMatches
    alt Configuration matches
        C->>D: Start or continue work
        D->>M: Execute turn
    else Configuration differs and daemon is idle
        C->>D: "daemon.stop(ifIdle=true)"
        D->>D: Stop accepting requests
        alt Turn request or active turn exists
            D->>D: Resume accepting requests
            D-->>C: Retryable rejection
        else Still idle
            D-->>C: Stopping
            C->>D: Start replacement daemon
        end
    else Configuration differs and work is active
        D-->>C: DAEMON_CONFIG_CHANGED
    end
Loading

Reviews (3): Last reviewed commit: "fix(agents): refresh daemon provider con..." | Re-trigger Greptile

Comment thread src/local-agent-config.ts
Comment thread src/local-agent-client.ts
@Waishnav
Waishnav force-pushed the codex/agent-daemon-config-revision branch 2 times, most recently from 2058304 to 8c44d60 Compare August 31, 2026 02:18
@Waishnav Waishnav closed this Aug 31, 2026
@Waishnav Waishnav reopened this Aug 31, 2026
@Waishnav
Waishnav force-pushed the codex/agent-daemon-config-revision branch from 8c44d60 to f7289d8 Compare August 31, 2026 02:35
@Waishnav Waishnav closed this Aug 31, 2026
@Waishnav Waishnav reopened this Aug 31, 2026
@Waishnav
Waishnav force-pushed the codex/agent-daemon-config-revision branch from f7289d8 to 46a8a38 Compare August 31, 2026 02:48
@Waishnav
Waishnav force-pushed the codex/agent-daemon-config-revision branch from 46a8a38 to cdffbd2 Compare August 31, 2026 13:38
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