Skip to content

Keep reporting a hosted agent refused for its connection - #2903

Merged
alexeyzimarev merged 2 commits into
mainfrom
alexeyzimarev/ai-5819-keep-reporting-a-hosted-agent-the
Nov 18, 2026
Merged

alexeyzimarev merged 2 commits into
mainfrom
alexeyzimarev/ai-5819-keep-reporting-a-hosted-agent-the

Conversation

@alexeyzimarev

Copy link
Copy Markdown
Member

Closes #2901 — AI-5819

What & why

A hosted agent whose re-registration the server refused with not_a_daemon or connection_vanished was silenced for the rest of the daemon's life. The next DaemonConnect left it out, and the server failed it as "agent no longer running" while it kept working. Both refusals are about the connection rather than the agent, so the re-registration pass now skips such an agent for that pass and leaves it reported, forwarder and cloud mirror included. The registration that follows the slot's recovery sends it again. A refusal about the agent still silences it

Where to look

A connection refusal also leaves ResumeAnswered unset. The server returns it before reading the registration, so a resumed agent's next announcement must still carry the first-announce flag, or the session is not reopened. The launch path's RegisterAgentAsync keeps its refusal rule

Verification

  • The new tests fail before the fix (agent missing from the live list, second re-announcement never sent, mirror stopped) and pass after it
  • Capacitor.Cli.Daemon.Tests.Unit: 6416 total, 0 failed, 78 skipped
  • dotnet publish src/Capacitor.Cli/Capacitor.Cli.csproj -c Release: no IL2026/IL3050 warnings

🤖 Generated with Claude Code

The resume flag stays unanswered too: the server returns both refusals
before it reads anything the registration carries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Nov 18, 2026

Copy link
Copy Markdown

AI-5819

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The daemon now treats not_a_daemon and connection_vanished re-registration refusals as connection-specific. It leaves the agent live and does not stop its ACP work or cloud sink, allowing a later registration pass to retry.

Changes: Re-registration refusal handling

Layer / File(s) Summary
Classify and handle connection-specific refusals
src/Capacitor.Cli.Core/AgentRegisteredResponse.cs, src/Capacitor.Cli.Daemon/Services/AgentOrchestrator.cs
AgentRegisteredResponse exposes RefusesConnection for unregistered responses with NotADaemon or ConnectionVanished. ReRegisterAgentsAsync logs these refusals and stops retrying for that agent during the current pass without marking it refused or stopping its work.
Verify subsequent reporting behavior
test/Capacitor.Cli.Daemon.Tests.Unit/Services/AgentOrchestratorVendorTests.cs, test/Capacitor.Cli.Daemon.Tests.Unit/Services/AgentOrchestratorCloudSinkTests.cs, test/Capacitor.Cli.Daemon.Tests.Unit/Services/AgentOrchestratorResumeOnBootTests.cs
Tests check that the agent remains live, its mirror continues sending output, and re-announcements retain the first-announcement flag. They also check that a later pass registers the agent and sends its status.

Assessment against linked issues

Objective Addressed Explanation
Keep agents live after not_a_daemon or connection_vanished re-registration refusals, and register them on a later pass [#2901] ✅

Possibly related PRs

  • kurrent-io/kcap#2314: Adds the resume first-announcement behavior exercised by the new re-announcement test.

Severity of issue fixed: High

Merge Risk: Minimal · up to e772d

Hosted agents refused re-registration only because of their connection now stay live and reported, and are registered again on a later pass. Refusals about the agent itself still silence it. No merge-blocking risk is identified.

Security architecture risk: Minimal · up to e772d

The change preserves running work during connection recovery while retaining rejection handling for work the server actually refuses. The inspected change establishes no new security or failure-containment regression.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The changed loop operates on this daemon's in-memory Starting or Running agents that are not server-silent. Preserved terminal output uses the existing agent ID and server connection; the new branch introduces no alternative destination or credential input.

Trust Boundaries and Controls

  • observed — The server response remains the classification input. Refusal reasons outside the two connection-specific values still set RegistrationRefused and suppress future registration and forwarding. The existing regression test checks that an agent-level refusal is not retried on a subsequent pass.

Resilience and Maintainability Implications

  • observed — The preserved mirror still checks connection readiness before sending, honors cancellation, and bounds repeated send failures before marking itself desynchronized. These are client-side containment controls, not proof of server-side ownership enforcement after a connection refusal.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: ec40c7f8-63c4-45a4-b38f-a536c2fecb3a
Commits

Reviewing files that changed from the base of the PR and between 185229d and e772dff.

Files selected for processing: 1

  • test/Capacitor.Cli.Daemon.Tests.Unit/Services/AgentOrchestratorVendorTests.cs
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 9 remain after this review.

@coderabbitai coderabbitai 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.

Additional comments: 1

test/Capacitor.Cli.Daemon.Tests.Unit/Services/AgentOrchestratorCloudSinkTests.cs: 1

181-185: Trivial · Maintainability & Code Quality · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Exercise mirror replay after the connection recovers.

CaptureServerConnection stays ready in this test. The test catches a stopped pump, but it would still pass if the accepted re-registration failed to replay output retained during the refusal. Set Ready to false before the refused pass and emit after; while it is false. Run an accepted pass, restore readiness, and assert one reset followed by before;after;, as in the neighboring replay test. (raw.githubusercontent.com)

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 491e94c1-0295-4fc4-8804-a9740d7db403
Commits

Reviewing files that changed from the base of the PR and between 9361605 and 185229d.

Files selected for processing: 5

  • src/Capacitor.Cli.Core/AgentRegisteredResponse.cs
  • src/Capacitor.Cli.Daemon/Services/AgentOrchestrator.cs
  • test/Capacitor.Cli.Daemon.Tests.Unit/Services/AgentOrchestratorCloudSinkTests.cs
  • test/Capacitor.Cli.Daemon.Tests.Unit/Services/AgentOrchestratorResumeOnBootTests.cs
  • test/Capacitor.Cli.Daemon.Tests.Unit/Services/AgentOrchestratorVendorTests.cs
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexeyzimarev
alexeyzimarev added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 6de8ed6 Nov 18, 2026
18 checks passed
@alexeyzimarev
alexeyzimarev deleted the alexeyzimarev/ai-5819-keep-reporting-a-hosted-agent-the branch November 18, 2026 13:54
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.

Keep reporting a hosted agent the server refused as not_a_daemon

1 participant