feat: simplify opencode prompt send#164
Conversation
Co-authored-by: Son Dao <son.dao@katalon.com>
There was a problem hiding this comment.
Pull request overview
This PR simplifies Thor’s Runner /trigger contract and Gateway dispatch flow by removing the “busy/status/wait” retry mechanism and standardizing successful trigger responses to NDJSON (always starting with a start event). It also replaces dynamic model context-limit loading with a hardcoded model-limit table for supported OpenAI models, updating tests and documentation accordingly.
Changes:
- Runner: remove session
status()busy check + abort settle wait; always returnapplication/x-ndjsonon success (one-linestartwhenstream=false, full stream todonewhenstream=true). - Gateway: drop
{ busy: true }handling and stop parsing successful runner bodies; simplifyTriggerResultto{ rejected: true|false }. - Runner: replace provider-based model limit fetching/caching with a constant
MODEL_CONTEXT_LIMITSmap and update trigger tests.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/runner/src/index.ts | Simplifies /trigger orchestration, unifies successful responses to NDJSON, removes busy/status/wait flow, and switches to constant model context limits. |
| packages/runner/src/trigger.test.ts | Updates trigger harness/tests to assert NDJSON start receipt, no status checks, interrupt behavior, and new model-limit expectations. |
| packages/runner/src/event-bus.ts | Removes waitForSessionSettled helper now unused after abort-settle logic removal. |
| packages/runner/src/event-bus.test.ts | Removes unit tests for waitForSessionSettled and updates imports/fixtures accordingly. |
| packages/gateway/src/service.ts | Simplifies runner trigger result contract; drops success-body parsing and {busy:true} retry behavior. |
| packages/gateway/src/service.test.ts | Updates gateway tests to treat any 2xx runner response as accepted and removes {busy:true} fixtures. |
| packages/gateway/src/app.ts | Removes “busy” outcome logging/branching; treats only rejected vs fired outcomes. |
| packages/gateway/src/app.test.ts | Updates gateway integration tests to reflect new runner response behavior and retry-on-5xx. |
| packages/gateway/src/queue.ts | Updates queue docs/comments to describe retryable failures rather than “runner busy”. |
| packages/gateway/src/queue.test.ts | Updates test comment to reflect deferred retry semantics. |
| packages/common/src/service-env.ts | Removes ABORT_TIMEOUT runner env since abort-settle waiting is removed. |
| docs/plan/2026052702_simplify-opencode-prompt-send.md | Adds/updates the design plan documenting the new NDJSON contract and simplified control flow. |
| AGENTS.md | Adds contributor guidance to keep MODEL_CONTEXT_LIMITS aligned with OpenCode model config changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| throw new Error(`Runner returned ${response.status}: ${text}`); | ||
| } | ||
|
|
There was a problem hiding this comment.
Addressed in 1017aa2: the gateway now best-effort cancels successful runner response bodies before returning, and I added a service test covering the cancel path.
AI-generated — verify before acting. View Thor context
Co-authored-by: Son Dao <son.dao@katalon.com>
| - `emit()` (`:989-1026`) gates `res.write()` on the `stream` flag at `:1013`. The `start` event is already constructed at `:1028-1033` but never reaches the wire in fire-and-forget mode. | ||
| - Gateway consumer: `packages/gateway/src/service.ts:543-573`. Reads `json.busy`; that is the only field it consumes from the success body. Confirmed by grep — no callsite reads `accepted`, `sessionId`, or `resumed` from the gateway side. | ||
| - Dispatch handler busy-log: `packages/gateway/src/app.ts:1154-1161`. The `result.busy` branch returns without calling `ack()`; that is what causes the queue to retain the file for the next scan (`packages/gateway/src/queue.ts:70-74`). | ||
| - Verified behavior of opencode (from reading `/Users/son.dao/repos/daohoangson/opencode`): |
There was a problem hiding this comment.
Updated in 57f6421: the plan now references the public upstream source at https://github.com/anomalyco/opencode instead of the local absolute path.
AI-generated — verify before acting. View Thor context
Co-authored-by: Son Dao <son.dao@katalon.com>
|
@copilot resolve the merge conflicts in this pull request |
Resolved in commit The four conflicting files were resolved as follows:
|
|
@copilot resolve the merge conflicts in this pull request |
Resolved in commit |
Summary
startTesting
AI-generated — verify before acting. View Thor context