test(agent): vitest suite + CI for the agent runner; fix relay error bug#4784
test(agent): vitest suite + CI for the agent runner; fix relay error bug#4784mmabrouk wants to merge 2 commits into
Conversation
Convert the hand-run tsx/node:assert scripts under services/agent/test/ into a vitest suite in tests/unit/ (describe/it, node:assert kept). Add vitest + typescript devDeps, scripts (test/typecheck/coverage), a node-env vitest.config (junit + v8 coverage), and broaden the tsconfig include so typecheck covers tests + config. Add a run-services-node-unit-tests job to 12-check-unit-tests.yml, and a services/agent/AGENTS.md. Testability seam: server.ts exports createAgentServer(run); cli.ts exports runCli(raw, stream, io) with an injectable engine + output sink, so the HTTP and CLI paths are tested with a fake engine (server.test.ts, cli.test.ts). src/entry.ts isEntrypoint keeps the entrypoints inert on import. Add src/version.ts + a richer GET /health; version 0.0.0 -> 0.1.0. Fix a real bug in tools/dispatch.ts: relayToolCall referenced an undefined callRef in its error/timeout messages (would throw ReferenceError and mask the real failure); use toolName, plus a focused relay regression test. Result: 10 test files / 47 tests pass, tsc --noEmit clean. Two tests are deferred because their deps live on sibling branches: skills.test.ts (needs engines/skills.ts from feat/agenta-on-rivet) and wire-contract.test.ts (needs the shared Python golden fixtures). They land when those reach this branch. Claude-Session: https://claude.ai/code/session_01GLA8RywSLTGiJvBrDnqZa2
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
docs/design/agent-workflows/typescript-structure/research.md (2)
11-35: 💤 Low valueAdd language specifier to the fenced code block (lines 11–35).
The file-tree block would benefit from a language tag for better syntax highlighting and markdown linting compliance.
📝 Proposed fix
-``` +```bash services/agent/ standalone pnpm package "agenta-agent-pi-wrapper"
79-82: 💤 Low valueAdd language specifier to the fenced code block (lines 79–82).
The structure listing would benefit from a language tag.
📝 Proposed fix
-``` +```text code-tool.test.ts continuation.test.ts mcp-servers.test.ts responder.test.tsservices/agent/src/cli.ts (1)
29-34: 💤 Low valueCLI dispatcher logic differs from server.ts.
The
runAgentdispatcher here defaults unknown/unset backends torunPi, butserver.ts(lines 53-55) falls back torunRivetwhenrequest.harnessorrequest.sandboxis set. This means a request with{harness: "claude"}and no explicitbackendruns on Rivet via the HTTP path but Pi via CLI.If this is intentional for CLI simplicity, consider adding a brief comment. If not, align the fallback logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3ada8826-4a3b-4dd7-9ed5-525aea827aee
⛔ Files ignored due to path filters (1)
services/agent/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (35)
.github/workflows/12-check-unit-tests.yml.gitignoredocs/design/agent-workflows/typescript-structure/README.mddocs/design/agent-workflows/typescript-structure/context.mddocs/design/agent-workflows/typescript-structure/plan.mddocs/design/agent-workflows/typescript-structure/research.mddocs/design/agent-workflows/typescript-structure/status.mdservices/agent/AGENTS.mdservices/agent/CLAUDE.mdservices/agent/package.jsonservices/agent/src/cli.tsservices/agent/src/entry.tsservices/agent/src/server.tsservices/agent/src/tools/dispatch.tsservices/agent/src/version.tsservices/agent/test/code-tool.test.tsservices/agent/test/continuation.test.tsservices/agent/test/extension-tools.test.tsservices/agent/test/mcp-servers.test.tsservices/agent/test/responder.test.tsservices/agent/test/stream-events.test.tsservices/agent/test/tool-bridge.test.tsservices/agent/test/tool-dispatch.test.tsservices/agent/tests/unit/cli.test.tsservices/agent/tests/unit/code-tool.test.tsservices/agent/tests/unit/continuation.test.tsservices/agent/tests/unit/extension-tools.test.tsservices/agent/tests/unit/mcp-servers.test.tsservices/agent/tests/unit/responder.test.tsservices/agent/tests/unit/server.test.tsservices/agent/tests/unit/stream-events.test.tsservices/agent/tests/unit/tool-bridge.test.tsservices/agent/tests/unit/tool-dispatch.test.tsservices/agent/tsconfig.jsonservices/agent/vitest.config.ts
💤 Files with no reviewable changes (8)
- services/agent/test/extension-tools.test.ts
- services/agent/test/responder.test.ts
- services/agent/test/code-tool.test.ts
- services/agent/test/tool-dispatch.test.ts
- services/agent/test/tool-bridge.test.ts
- services/agent/test/stream-events.test.ts
- services/agent/test/continuation.test.ts
- services/agent/test/mcp-servers.test.ts
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Stacks on
feat/agent-runner-engines.What
The agent runner (
services/agent) had 8 hand-runtsx/node:asserttest scripts, nopnpm test, no CI, and no typecheck gate. This adds a real test setup and wires it into CI.tests/unit/*.test.ts(describe/it,node:assertkept), plusvitest.config.ts(node env, junit, v8 coverage) and scripts (test,test:watch,test:coverage,typecheck).run-services-node-unit-testsjob in12-check-unit-tests.yml(Node 24, frozen install, typecheck, test:unit, publish junit).tsconfiginclude broadened to covertests/+vitest.config.ts.server.tsexportscreateAgentServer(run)andcli.tsexportsrunCli(raw, stream, io)with an injectable engine, so the HTTP and CLI paths are tested with a fake engine (server.test.ts,cli.test.ts).src/entry.ts isEntrypointkeeps the entrypoints inert when imported.src/version.ts+ a richerGET /health({status, runner, protocol, engines, harnesses}); version0.0.0->0.1.0.services/agent/AGENTS.md+ the planning workspace underdocs/design/agent-workflows/typescript-structure/.Bug fix
tools/dispatch.tsrelayToolCallreferenced an undefinedcallRefin its error/timeout messages — on a Daytona relay failure it would throwReferenceError: callRef is not definedand mask the real error. Now usestoolName, with a focused relay regression test. The new typecheck gate catches this class of bug.Result
pnpm test= 10 files / 47 tests pass;tsc --noEmitclean.Deferred (dependency on a sibling branch)
skills.test.tsneedsengines/skills.ts(onfeat/agenta-on-rivet).wire-contract.test.tsneeds the shared Python golden fixtures (on the SDK/service branch).Both land when those reach this branch.
https://claude.ai/code/session_01GLA8RywSLTGiJvBrDnqZa2