Skip to content

fix: Add proxy health reuse guard, await child.exited for SSE stream#30

Open
remy90 wants to merge 1 commit intoNomadcxx:mainfrom
remy90:main
Open

fix: Add proxy health reuse guard, await child.exited for SSE stream#30
remy90 wants to merge 1 commit intoNomadcxx:mainfrom
remy90:main

Conversation

@remy90
Copy link
Contributor

@remy90 remy90 commented Feb 13, 2026

The plugin reuses an existing proxy on 127.0.0.1:32124 by checking /health.
/health did not include workspace identity, so a proxy started in one workspace (e.g. ~/.config/opencode) could be reused by sessions in another workspace (e.g. ~/git/foo).
Result: cursor-agent runs with stale --workspace, and file writes are incorrectly blocked outside that stale directory.

Root fix:

  • Proxy reuse is now workspace-aware:
    • /health includes workspaceDirectory
    • reuse only occurs when health workspace matches requested workspace otherwise start a fresh proxy (including random-port fallback on EADDRINUSE)
    • Workspace comparison is normalised and platform-aware:
    • Bun streaming now waits for actual process exit await child.exited before deciding success vs error, preventing premature SSE termination.

Adjacent SSE fix:
In Bun streaming path, completion/error decision relied on child.exitCode directly, which can be null until process fully exits.
This race can emit terminal/error behaviour prematurely and truncate SSE output.

Full disclosure, AI was used in this PR and I don't claim to have taken the time to understand Plugin.ts however, I have tested this for this machine and can confirm that this plugin now 'works on my machine'.

@remy90
Copy link
Contributor Author

remy90 commented Feb 13, 2026

I believe this unrelated but I've noticed the following behaviour:

Tool loop guard stopped repeated successful calls to "edit" after 4 attempts (limit 3). 

This likely indicates a model/tool-call loop; adjust prompt or tool strategy and retry.

^I'm getting this quite often. I can look into this in more depth but would probably want to segment PRs, as streaming and writes now work, even if there are regular tool loop guard limits in place

@Nomadcxx
Copy link
Owner

Thanks for this man, just saw this then. I'll check it out tomorrow afternoon when I'm back home. I tweaked the loop guard today, updated the prompt builder, reduced logging in main build .. so there is less looping, logging, errors overall from last few tests. Still very difficult to get tools and skills working correctly here because cursor-agent is a blackbox so its testing/iteration/refinement to see what works here and what doesn't (a real pain in the butt) but managed to one-shot a pong game in Go with Auto today. It's a crap model so it did poorly but it pulled the correct tools, wrote in the right directories seemed like it remembered context correctly.. we will get there soon I think I'm guessing another week.

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.

2 participants