Files
kandev/apps
João Salavisa f39e7b06ca fix(agent): honor session passthrough snapshot when starting agent process (#1003)
* fix(agent): honor session passthrough snapshot when starting agent process

Tasks created in agent (ACP) mode got stuck in "starting" after toggling
the profile's cli_passthrough flag and restarting the server.
StartAgentProcess re-resolved the live profile each launch, so the new
flag rerouted existing ACP sessions into the passthrough path (and vice
versa), where the workspace plumbing didn't match.

Snapshot session.IsPassthrough onto LaunchAgentRequest /
lifecycle.LaunchRequest / AgentExecution and let StartAgentProcess use
that as the source of truth. Sessionless launches (legacy
controller.LaunchAgent) still fall back to live profile resolution.

Fixes #981.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(agent): make passthrough snapshot the sole routing signal in StartAgentProcess

Bot review feedback follow-up (#1003):

- Route on the snapshot alone (new routePassthrough helper). A transient
  ResolveProfile error no longer silently routes a passthrough session
  to ACP — the fresh path surfaces an explicit error, the resume path
  surfaces the existing resolvePassthroughAgent error.
- Add TestStartAgentProcess_PassthroughResume_SurvivesProfileResolveError
  and TestStartAgentProcess_FreshPassthrough_SurfacesProfileResolveError
  to lock the no-silent-ACP-fallback invariant.
- Add TestLaunchPreparedSession_PropagatesIsPassthrough mirroring the
  resume-path propagation test so both build paths are independently
  covered.
- Strip issue-number references from source/test comments per project
  convention.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(agent): avoid double ResolveProfile in sessionless passthrough path

routePassthrough now returns (bool, *AgentProfileInfo). When the
sessionless fallback path already resolved the profile, it threads it
back so StartAgentProcess can reuse it for command building instead of
calling ResolveProfile a second time. Snapshot-driven routing still
returns nil so the snapshot path resolves fresh — the snapshot
deliberately outlives any particular live profile state.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(agent): extract startPassthroughExecution to satisfy nestif

CI's golangci-lint flagged the nested-if complexity of the passthrough
dispatch block in StartAgentProcess after the previous round of fixes
pushed it past nestif's threshold of 5. Move the resume-vs-fresh
branching plus the lazy profile resolution into a startPassthroughExecution
helper so StartAgentProcess becomes a single short routing decision.

No behavior change.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* docs: drop caller reference from startPassthroughExecution comment

Per project convention, source comments shouldn't name the calling
function — the reason it's its own method is captured by its contract
(profileInfo nullability + routePassthrough handoff), not by the
caller's name.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 23:39:23 +01:00
..