Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions docs/sdk-task-intent-revisions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# User corrections and task revisions

Enable `taskIntent: true` on `MossAgent` to reconcile real user input in the existing model response. This feature does not call a second classifier. It requires native structured tool calls; providers must expose `turn_decision` alongside ordinary tools.
Enable `taskIntent: true` on `MossAgent` to reconcile real user input in the existing model response. Providers expose `turn_decision` alongside ordinary tools for task changes and action plans.

```ts
const agent = new MossAgent({ ...config, taskIntent: true });
Expand All @@ -16,7 +16,14 @@ agent.steer(sessionKey, correction, { id: stableCorrectionId, taskId });

The model proposes field-level changes and a plan through `turn_decision` in its normal response. Runtime checks input identity, exact source quotations, schema and the captured revision before committing. Unmentioned fields survive. This validates protocol and provenance, not the semantic correctness of an interpretation. Missing user information should produce `clarify`.

`answer` finishes the turn with a complete reply that needs no further tools.
A complete final text response can answer the current input without a decision.
For an ordinary input batch, Moss records a `replied` inbox receipt, preserves the
task state and plan, and grants no execution authorization. A batch with a
task-bound input, steer, or explicit invalidation stays pending until a valid
decision resolves it. A standalone text reply can still be delivered with
`task_intent_hold` for that batch.

A valid `answer` decision may carry a complete reply and context corrections.
`execute` continues the turn with a concrete plan whenever tools are still needed,
including read-only searches, documentation lookups and file reads. This selects
continuation and does not grant permissions or bypass tool approval. A promise to
Expand All @@ -29,10 +36,10 @@ decision must follow host-specific rules. The synchronous callback receives a
copy of the parsed `TurnDecision` with any runtime-bound fields filled in. Return
without a value to continue to the SDK's commit checks. Throw an error with
model-facing repair guidance to reject the decision and every business call in
the response. The input stays pending while the same run repairs the declaration
internally. Protocol failures do not pause the task or ask the user to retry;
the ordinary run budget and cancellation still bound this work. Use a short error
message suitable for the model with sensitive details omitted.
the response. Rejected decision arguments never qualify as reply text. If the
model supplies no independent final reply, Moss repairs the pending declaration
in the same run. Use a short error message suitable for the model with sensitive
details omitted.

In versioned sessions, the runtime owns the captured revision, sequence and input
IDs. It also binds exact repeated input citations to the latest identical input
Expand Down
33 changes: 33 additions & 0 deletions docs/specs/2026-12-04-publish-plain-replies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 正常交付纯文本回复

## 问题

RDK Studio 的同一会话里,用户追问“你不是内置了示例图吗”,模型请求成功,但 Moss 在首轮和三轮补救后仍未接受 `turn_decision`,Studio 最终提示任务暂停。用户随后换了一种问法,同一会话继续执行。一次已经正常结束的对话回复不应因为缺少任务决策而被丢弃。

## 行为

- 模型为当前输入正常结束并返回独立的可见正文,且这条模型消息没有请求执行业务工具时,Moss 交付正文。有有效的 `turn_decision` 时照常验证并提交,包括 `answer` 携带的上下文修正。
- 正文资格使用现有的文本识别和正常结束条件(`end_turn`、`stop_sequence`)。仅独立的 assistant 文本块可走纯文本路径。无效决策的 `answer` 字段、协议 JSON、思考、工具调用前言及截断片段均不算正文。缺失或无效决策若伴随符合条件的正文,直接交付正文,无需启动决策补救;没有合格正文时沿用现有校验和补救。已被新输入替代的输出沿用现有版本判断。
- 输入批次只有普通对话时,通过现有收件箱将该批输入记为已回复,下一轮无需重处理。这条回执不构成有效决策或执行授权,任务目标、约束、计划和状态沿用原值。
- 批次含宿主显式修订(如“补充当前任务”)或任务失效输入时,正常正文照常交付。纯文本结算不推进该批的 `processedSeq),现有待处理记录保留,直到有效决策处理。旧审批和未发出的工具继续受现有版本、取消与审批约束。
- Studio 按同一会话的正常回复路径展示和保存当前输入的正文。显式修订仍待处理时,任务状态可保留暂停。“模型未能确认……”用于没有正文可交付的未决结果,实际正文优先。

## 实现位置

1. 在 Moss 的响应结算和 `TaskIntentTurn` 对接处接通纯文本回复,沿用现有的可见内容、停止原因和输入版本判断。通过现有输入收件箱记录普通回复及关联输入。
2. 用原生回归覆盖新行为。更新以“缺少决策”为目的的旧测试夹具,使其返回真正缺少可交付正文的响应。保留原有决策校验、过期调用和审批测试。
3. 用 Studio 在本地加载候选 Moss 构建,验证正文和已有任务状态在最终事件及会话历史中的呈现。只有宿主现有结算会丢正文时才调整宿主。

## 验收

| 场景 | 预期 |
| ------------------------------------------------ | ---------------------------------------------------------- |
| MiniMax 兼容接口返回完整纯文本,缺少决策 | 首次模型请求即交付正文,下一轮可在同一会话继续 |
| 模型返回有效 `answer` 决策及正文 | 正常回复,决策中有效的上下文修正照常应用 |
| 运行中补充“别重启,只看日志”,模型仅回复“收到” | 聊天显示“收到”,待处理修订保持可处理,旧的重启调用没有执行 |
| 同批含普通问题与显式修订,模型只有纯文本 | 正文可见,批次的任务修订仍待处理 |
| 正常结束的独立正文与无效纠错决策并存 | 正文可见,无状态提交,纠错不生效 |
| 缺少决策且只提供业务调用,或无效决策仅有协议载荷 | 沿用现有补救与停止原因,业务调用继续受原有校验 |
| 本轮还未结算就收到更新输入 | 新输入接管,旧正文和旧审批沿用当前版本规则 |

范围包括 Moss 和 Studio 的本轮结算。网关、模型配置和只读工具的授权沿用现状。
2 changes: 1 addition & 1 deletion packages/contracts/src/task-intent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface TurnDecision {
}

export interface TaskIntentReceipt {
status: 'pending' | 'committed' | 'needs_clarification' | 'failed';
status: 'pending' | 'replied' | 'committed' | 'needs_clarification' | 'failed';
revision?: number;
}

Expand Down
Loading
Loading