fix(subagent): align SDK stop reasons after master merge

This commit is contained in:
Tianyi Cui
2026-07-27 23:08:16 +08:00
parent 7f333d8837
commit cb12fa7b90
5 changed files with 7 additions and 6 deletions

View File

@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/subagent/subagent-dsh-sdk/README.md
README.md: 904b70f4d197f1d5082521b519dde89b165324ef
README.zh.md: f5879e7ae0924ac5ec2786b115bd4b9f9215c9da
README.md: 95ddd154c8262e8854280e74618bdd9be9c938c0
README.zh.md: c10145f34cd785d10f4b660a5f6414455ad42464

View File

@@ -16,7 +16,7 @@ The returned run id is minted in the parent namespace; the child runtime's sessi
## Stop-reason mapping
The child reports its turn outcome as a structured `TurnEndReason` on `session.finished`; the provider maps it into the seam vocabulary. `completed``completed`, `max-tokens``max-tokens`, `aborted``aborted`; everything else — `error`, `rejected`, `interrupted`, `disposed`, a future variant, or a turn that never ran — maps to `error`, so an unclean stop is never reported as success. Transport-level failures after publication flatten to `stopReason: 'error'` through the `onError` diagnostic sink (wired to `ctx.logger.warn`); the seam contract forbids `result` rejecting.
The child reports its turn outcome as a structured `TurnEndReason` on `session.finished`; the provider maps it into the seam vocabulary. `completed``completed`, `max-tokens``max-tokens`, `aborted``aborted`; everything else — `error`, `interrupted`, `disposed`, a future variant, or a turn that never ran — maps to `error`, so an unclean stop is never reported as success. Transport-level failures after publication flatten to `stopReason: 'error'` through the `onError` diagnostic sink (wired to `ctx.logger.warn`); the seam contract forbids `result` rejecting.
## Capabilities and context

View File

@@ -16,7 +16,7 @@ SDK provider 把每个子代理作为一个完整的 DeepSeek Harness 运行时
## 停止原因映射
子进程在 `session.finished` 上以结构化 `TurnEndReason` 报告回合结局provider 把它映射进接缝词汇表。`completed``completed``max-tokens``max-tokens``aborted``aborted`;其余一切——`error``rejected``interrupted``disposed`、未来变体、或根本没跑回合——映射为 `error`,不洁终止绝不报告为成功。发布后的传输层失败经 `onError` 诊断汇(接到 `ctx.logger.warn`)压平为 `stopReason: 'error'`;接缝契约禁止 `result` 拒绝。
子进程在 `session.finished` 上以结构化 `TurnEndReason` 报告回合结局provider 把它映射进接缝词汇表。`completed``completed``max-tokens``max-tokens``aborted``aborted`;其余一切——`error``interrupted``disposed`、未来变体、或根本没跑回合——映射为 `error`,不洁终止绝不报告为成功。发布后的传输层失败经 `onError` 诊断汇(接到 `ctx.logger.warn`)压平为 `stopReason: 'error'`;接缝契约禁止 `result` 拒绝。
## 能力与上下文

View File

@@ -81,7 +81,7 @@ export function sdkStopReason(reason: TurnEndReason | undefined): SubagentStopRe
return 'max-tokens'
case 'aborted':
return 'aborted'
// error / rejected / interrupted / disposed / a future merged variant /
// error / interrupted / disposed / a future merged variant /
// no turn at all: the task did NOT finish cleanly — surface a generic
// failure so the consumer maps it to an isError result.
default:

View File

@@ -75,7 +75,8 @@ describe('sdkStopReason', () => {
expect(sdkStopReason({ kind: 'max-tokens' })).toBe('max-tokens')
expect(sdkStopReason({ kind: 'aborted' })).toBe('aborted')
expect(sdkStopReason({ kind: 'error', step: 0, message: 'x' })).toBe('error')
expect(sdkStopReason({ kind: 'rejected', reason: 'policy' })).toBe('error')
expect(sdkStopReason({ kind: 'interrupted' })).toBe('error')
expect(sdkStopReason({ kind: 'disposed' })).toBe('error')
})
it('treats an absent or unknown reason as an error', () => {