Large File Creation with Coding Agent Issue

I keep on hitting this issue of the coding agent getting “terminated” after like 600s+ (have seen it get up to 1300s) on sparks. I basically asked it to make solitaire in one html page with a few requirements for model testing.

Architecture
OpenCode/Pi ↔ HAProxy ↔ LiteLLM VM ↔ llama-swap ↔ community vLLM

Everything is up to date minus llama-swap, which is 2 versions behind due to the latest version not unloading correctly.

Things I have tried so far:

  • Use a different coding agent. I tried both OpenCode and Pi Agent, just to ensure it was not an OpenCode specific issue, but Pi also has the same error. I also tried just using Minimax M3 Free (online) in OpenCode and it completes the file.
  • Extending proxy timeout and remove HA Proxy. No real difference.
  • Remove LiteLLM all together since llama-swap technically also support OpenAI API, but it then fails with terminated.
  • Check the logs for llama-swap. nothing stood out as the root cause. A few times llama-swap reported continued token generation even after the termination message on the coding agent.
  • Check the log tail for litellm (all green and status of success)

Has anyone experienced something similar before? Any help would be much appreciated.

Not in this combi. But the default timeouts of your proxies in front of your chain might be to low. I experienced this with NGINX as SSL terminator in front of vLLM which large contexts. Had some requests which took 6 minutes and longer.

Do you see gateway timeout errors (504) in your clients? Or only “terminated”?

Why a proxy (HAProxy) in front of a proxy (LiteLLM)?

llama-swap fails with terminated? What does the vLLM log say at that time when llama-swap terminates?

Try a direct connection between vLLM and your clients (OpenCode/Pi). If it still persists try tuning OpenCode or Pi in terms of timeouts.

You could get metrics out of vLLM with Prometheus/Grafana to see how long the requests need from end to end.

I ran into similar issues with Hermes agent and less frequently OpenCode, but different setup.

Hermes/OpenCode ↔ Nginx Proxy Manager ↔ vLLM and also direct connection from Hermes / OpenCode to vLLM.

Did the same things as you with increasing time outs and such and allowing direct connection to vLLM. Eventually dug up some information that the tool-call timeouts were not from the LLM interaction but the file I/O and that some tools have problems writing out files once the size becomes too big. So my solution is to instruct the agents to chunk up file output into 10KB or smaller chunks. The info I dug up said it tends to occur around 20KB, so I just went with half that. The main problem now is sometimes the agents ‘forget’ to chunk up the output.

Not an ideal solution, but a bandaid that is working for now.

I just use the HAproxy for easy SSL; I set the client/server timeout on HAproxy to 20 minutes. The “terminated” just show up in OpenCode. vLLM and LiteLLM seems to be continuing token gen afterward sometimes, which is kind of why its been difficult for me to troubleshoot. Folks put in issues for something similar for specific models for opencode, but they often do not include enough info to validate I got the exact same issue or those are not cloud gateway issues:

This is not very frequent. It only when the LLM is forced to create large single files, no issues when doing like small code changes on larger repos. @C_G are you just manually instructing on occurrence or just adding it to like your agents.md? I also had some luck just doing the manual prompt with like “API timed out, split file creation” and letting it re-run. I also usually get to between 20-30KB on failure.

Currently I have it in the agents.md or soul.md and only occasionally have to interrupt and bring it up if I notice tool-call failures. Before then I was doing it manually and let hermes put it in its memory, which was less consistently being followed.

This is a nodejs issue, which is why you experience it on different harness.

https://github.com/earendil-works/pi/issues?q=terminated

https://github.com/earendil-works/pi/issues/4519#issuecomment-4468511488

If I am reading this correctly, the fix was applied weeks ago to pi. I think was already on one of the patched versions, but let me give it a 2nd try and check on what version of node I am using. I did not even consider it could because all the harnesses I was testing relied on node.js, but that would explain why neither litellm or llama-swap provided any errors I could use. Thanks for the insight.

Same here. Local inference is fragile and there should be a better process to versioning.