Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

🐛 [Bug] Intermittent "ERR_STREAM_PREMATURE_CLOSE" loop during sub-agent delegation (sdd-apply)  #61

Description

@Milor123

📝 Bug Description

The orchestrator agent fails to delegate tasks to sub-agents (like sdd-apply). It enters a recursive loop where it attempts to call the skill, but fails immediately with Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close.

This behavior is intermittent: sometimes it works perfectly, and other times it gets stuck in this loop. Occasionally, the agent reports it "cannot find the provider," which is inconsistent because other agents using the exact same provider/model configuration continue to work fine.


🔄 Steps to Reproduce

  1. Use gentle-ai v1.7.5 on Windows 11.
  2. Initiate a task that requires the orchestrator to delegate work to a sub-agent (e.g., creating a backend core using sdd-apply).
  3. Observe the logs when the orchestrator attempts to call the sub-agent.
  4. The agent will attempt to retry the tool call multiple times, failing with the same stream error each time.

✅ Expected Behavior

The orchestrator should be able to call sub-agents/skills, the sub-agent should complete its task, and return the result to the orchestrator without closing the stream prematurely.


❌ Actual Behavior

The execution fails with:
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close

Image

The agent then enters a "Thinking" loop, trying different strategies (like using task tool instead of delegate), but keeps hitting the same error, effectively getting stuck.


🖥️ Environment

Gentle AI Version
v1.7.5

Operating System
Windows 11 (Build 25H2) - Installed via PowerShell

AI Agent / Client
OpenCode (Gentle AI Plugin)

Affected Area
Orchestration / Sub-agent delegation (Skills)


💡 Logs / Error Output

Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
Thinking: La delegación de implementación terminó pero parece que no se crearon archivos (el resultado muestra solo la búsqueda en engram). El directorio sigue vacío. Parece que el agente de apply no pudo completar la implementación.
Déjame intentar otra estrategia - voy a lanzar una nueva delegación más específica para crear el backend core.
→ Skill "sdd-apply"
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
Thinking: El skill sigue fallando. Voy a intentar con un approach diferente - crear los archivos directamente usando Write tool, ya que esto es una tarea de ejecución y el skill no está funcionando.
... (Repeated loop)

Additional Context

  • The issue is intermittent.
  • Sometimes it claims in others sdd "provider not found" even though the provider is correctly configured and working for other sub-tasks in the same session. (it looks like random problem) It doesn't happen every time and I don't understand why, it's so strange
  • Debugging note: I am not sure how to provide deeper debug logs or trace the internal Node.js stream failure in this specific environment. If there's a specific flag or command to get more verbose output, please let me know.

other bugs in the same command line

Thinking: Bien, la delegación se inició. Ahora espero la notificación de completitud.
⚙ delegation_read [id=: ]
Error: Delegation ": " not found.
Use delegation_list() to see available delegations.

opencode.json

opencode-personal.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstatus:needs-reviewAwaiting maintainer review

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions