Skip to content

fix(bridge): align CLI send body with AgentUserMessageInputDto + add … - #1

Merged
JecoShen merged 1 commit into
masterfrom
fix/bridge-send-message-shape
Aug 12, 2026
Merged

fix(bridge): align CLI send body with AgentUserMessageInputDto + add …#1
JecoShen merged 1 commit into
masterfrom
fix/bridge-send-message-shape

Conversation

@JecoShen

Copy link
Copy Markdown
Owner

…ARK compat warn

Three issues surfaced from end-to-end bridge testing against a real Volcengine Ark (Coding Plan / Doubao) deployment. Two of them are user- facing configuration gotchas captured in reference/harness/ark-models.md; the third is a real wire-contract bug in scripts/cli/bridge/commands/send.ts that the 28 server-side tests did not catch because they hit the route directly, never going through the CLI.

Fixes

  1. scripts/cli/bridge/commands/send.ts

    • The CLI historically sent message: {content: [{type:"text",text}]} (Anthropic-style), but the DTO AgentUserMessageInputDtoSchema = z.object({text: z.string()}).strict() only accepts {text: string}. Server replies 400 with "Invalid input: expected string, received undefined" because the strict zod object has no text field. Server-side tests mock harness directly so they never observe the wire body the CLI writes.
    • Switch the body to message: {text: input.message} and add a comment pinning the DTO contract as the single source of truth.
  2. scripts/cli/bridge/commands/send.test.ts (new)

    • Regression guard: capture the request body via stubbed fetch and assert the shape (mode, message.text, clientMessageId UUID, no caller/block/queueIfBusy leakage, followup mode, title passthrough, non-2xx → BridgeHttpError with response body). Prevents future drift between CLI and DTO.
  3. server/agent/harness/model-resolver.ts + model-resolver.test.ts

    • Add warnArkDeveloperRoleCompatIfNeeded heuristic and warnProviderCompatIssues scan. Detects reasoning+openai-completions models whose baseURL matches ark.<region>.volces.com and lack compat.supportsDeveloperRole: false — emits appLogger.warn once per (provider, model) per process. pi-ai 0.80.6 openai-completions adapter defaults to developer role when model.reasoning && compat.supportsDeveloperRole; ARK rejects developer with 400 InvalidParameter. Warning fires best-effort, never blocks harness startup; users can then patch compat and restart session.

Docs

  • reference/harness/ark-models.md (new): config.json template, the /v3/models lookup workflow for resolving ark-code-latest-style UI aliases to actual model ids, region baseURL table, timeout/retry recommendations, and a link back to the startup warn.
  • reference/harness/invoke-http.md: cross-reference to ark-models.md.
  • reference/README.md: add ark-models.md to the bookshelf and reading order.

Test infra

  • vitest.config.ts: include scripts/cli/**/*.test.ts so CLI tests run in the standard bunx vitest run invocation (previously excluded).

Verification

  • bunx vitest run scripts/cli/bridge server/agent/bridge server/agent/harness/pi-runtime-resolver → 53/53 tests pass (5 new send + 5 new model-resolver compat + 43 existing)
  • bunx tsc --noEmit -p tsconfig.json → 7 pre-existing Prisma client errors, 0 new errors from this change

Refs: end-to-end verification record in
~/.claude/projects/-www-wwwroot-book-neoshen-dpdns-org/memory/bridge-ark-e2e-verified.md

关联 Issue / Related issue

解决的问题 / Problem

本次范围 / Scope

包含 / In scope:

  • 待填写 / To be completed

不包含 / Out of scope:

  • 待填写 / To be completed

用户可见结果与实现 / User-visible result and implementation

验证 / Verification

实际执行的完整命令和结果 / Exact commands and results:


未运行的检查及原因 / Checks not run and why:

  • 待填写 / To be completed

界面证据 / UI evidence

文档与记录 / Documentation and records

  • 已更新或确认不需要更新用户文档 / User documentation updated or not needed
  • 已更新或确认不需要更新 Task walkthrough / Task walkthrough updated or not needed
  • 已更新或确认不需要更新 Reference、ADR 与 PROJECT-STATUS.md / Reference, ADR, and PROJECT-STATUS.md updated or not needed
  • 本 PR 不修改版本号或 RELEASE.md,除非维护者明确要求 / This PR does not change the version or RELEASE.md unless requested by a maintainer

风险与边界 / Risks and boundaries

  • 数据结构或迁移 / Data shape or migration: 待填写 / To be completed
  • 配置、安装或发布 / Configuration, installation, or release: 待填写 / To be completed
  • 安全与隐私 / Security and privacy: 待填写 / To be completed
  • 已知限制与后续事项 / Known limitations and follow-ups: 待填写 / To be completed

提交者确认 / Contributor confirmation

  • 一个连贯目标之外没有夹带其它改动 / This PR contains no unrelated changes outside one coherent goal
  • 我已审查并能解释全部改动,包括开发 Agent 生成的内容 / I reviewed and can explain every change, including coding-agent output
  • 验证结果真实,聚焦测试没有被描述成全量测试 / Verification is accurate and focused tests are not presented as the full suite
  • 日志、截图和 fixture 不含密钥、小说正文、私人会话或未授权内容 / Logs, screenshots, and fixtures contain no secrets, manuscripts, private sessions, or unlicensed material

…ARK compat warn

Three issues surfaced from end-to-end bridge testing against a real
Volcengine Ark (Coding Plan / Doubao) deployment. Two of them are user-
facing configuration gotchas captured in reference/harness/ark-models.md;
the third is a real wire-contract bug in scripts/cli/bridge/commands/send.ts
that the 28 server-side tests did not catch because they hit the route
directly, never going through the CLI.

Fixes
1. scripts/cli/bridge/commands/send.ts
   - The CLI historically sent `message: {content: [{type:"text",text}]}`
     (Anthropic-style), but the DTO
     `AgentUserMessageInputDtoSchema = z.object({text: z.string()}).strict()`
     only accepts `{text: string}`. Server replies 400 with
     "Invalid input: expected string, received undefined" because the
     strict zod object has no `text` field. Server-side tests mock harness
     directly so they never observe the wire body the CLI writes.
   - Switch the body to `message: {text: input.message}` and add a comment
     pinning the DTO contract as the single source of truth.

2. scripts/cli/bridge/commands/send.test.ts (new)
   - Regression guard: capture the request body via stubbed `fetch` and
     assert the shape (mode, message.text, clientMessageId UUID, no
     caller/block/queueIfBusy leakage, followup mode, title passthrough,
     non-2xx → BridgeHttpError with response body). Prevents future drift
     between CLI and DTO.

3. server/agent/harness/model-resolver.ts + model-resolver.test.ts
   - Add `warnArkDeveloperRoleCompatIfNeeded` heuristic and
     `warnProviderCompatIssues` scan. Detects reasoning+openai-completions
     models whose `baseURL` matches `ark.<region>.volces.com` and lack
     `compat.supportsDeveloperRole: false` — emits `appLogger.warn` once
     per (provider, model) per process. pi-ai 0.80.6 openai-completions
     adapter defaults to `developer` role when `model.reasoning &&
     compat.supportsDeveloperRole`; ARK rejects `developer` with 400
     InvalidParameter. Warning fires best-effort, never blocks harness
     startup; users can then patch compat and restart session.

Docs
- reference/harness/ark-models.md (new): config.json template, the
  /v3/models lookup workflow for resolving `ark-code-latest`-style UI
  aliases to actual model ids, region baseURL table, timeout/retry
  recommendations, and a link back to the startup warn.
- reference/harness/invoke-http.md: cross-reference to ark-models.md.
- reference/README.md: add ark-models.md to the bookshelf and reading
  order.

Test infra
- vitest.config.ts: include `scripts/cli/**/*.test.ts` so CLI tests
  run in the standard `bunx vitest run` invocation (previously excluded).

Verification
- `bunx vitest run scripts/cli/bridge server/agent/bridge server/agent/harness/pi-runtime-resolver`
  → 53/53 tests pass (5 new send + 5 new model-resolver compat + 43 existing)
- `bunx tsc --noEmit -p tsconfig.json` → 7 pre-existing Prisma client
  errors, 0 new errors from this change

Refs: end-to-end verification record in
  ~/.claude/projects/-www-wwwroot-book-neoshen-dpdns-org/memory/bridge-ark-e2e-verified.md
@JecoShen
JecoShen merged commit a7b04d2 into master Aug 12, 2026
2 of 7 checks passed
@JecoShen
JecoShen deleted the fix/bridge-send-message-shape branch August 12, 2026 17:30
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.

1 participant