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
31 changes: 31 additions & 0 deletions docs/sdk-task-intent-revisions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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.

```ts
const agent = new MossAgent({ ...config, taskIntent: true });
await agent.chat(sessionKey, rawText, {
userInput: { id: stableUserMessageId, text: rawText, taskId },
taskId,
});
// An internal planner/repair prompt is not a new user instruction.
await agent.chat(sessionKey, enginePrompt, { userInput: false, taskId });
// Admission persists the correction before returning its delivery receipt.
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. Ambiguous input should produce `clarify`, and capability questions should produce `answer`, with no business calls.

`getTaskIntent` returns the committed state plus the current pending-input barrier. `getTaskIntentReceipt` distinguishes semantic commit from canonical message delivery. Input IDs are session-scoped and must never be reused for different text. After the inbox payload limit, processed inputs retain compact hash/receipt tombstones so retries remain idempotent; these small identity records grow with the session.

With `sessionInboxDir`, input, receipt and the retryable task projection share the existing locked, fsynced inbox journal. A projecting entry blocks actions until recovery completes. Deterministically rejected projections remain failed/pending and may be superseded by a valid new input, including a fresh task binding. Storage errors fail closed.

Every action binds its original input sequence, intent revision and plan ID. Admission of newer input blocks remaining batch calls, approval continuations, automatic retries and stale task writes. Already-started external operations may finish; this mechanism does not roll back side effects. Suspended tools retain the existing explicit continuation protocol; hosts can admit a correction with `admitTaskInput`/`steer` before resuming, so the resumed model reconciles it before further actions.

For native tasks, `applyTaskRevision` commits a revision with an idempotent `revisionId` and `expectedRevision`. It retains the original goal for audit, invalidates the old plan and requires revision-matching evidence. `resumeTask(..., { replan: true })` plans before verification. Accepted task history is immutable. A PASS already dispatched at the native append boundary may finish settlement; later corrections belong to subsequent work.

Host callbacks outside normal tool execution must freeze the binding at callback creation and use `withTaskExecutionGuard(() => agent.assertTaskIntentCurrent(sessionKey, capturedIntent), action)`. Do not reread a new binding when an old callback wakes. Host evidence must also preserve its producing plan identity: stamping an old observation with the current revision does not make it current evidence.

The SDK defaults to the existing path when this option is absent. Studio enables it for ordinary runs, while fixed JSON execution profiles retain their own protocol.

Verification: `npm run verify` includes the `task-intent` stage, which exercises a scripted provider, durable recovery and native task revision/acceptance. These offline probes do not measure model interpretation accuracy or real-device behavior.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rdk-moss/agent",
"version": "0.36.0",
"version": "0.37.0",
"private": false,
"type": "module",
"license": "MIT",
Expand Down
3 changes: 3 additions & 0 deletions scripts/verify/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import { stage as loopPruneStage } from './stages/loop-prune.mjs';
import { stage as loopFollowStage } from './stages/loop-follow.mjs';
import { stage as loopCheckTimeoutStage } from './stages/loop-check-timeout.mjs';
import { stage as taskObservationStage } from './stages/task-observation.mjs';
import { stage as taskIntentStage } from './stages/task-intent.mjs';
import { stage as editRecoveryStage } from './stages/edit-recovery.mjs';
import { stage as loopHealthStage } from './stages/loop-health.mjs';
import { stage as runTestsVerdictStage } from './stages/run-tests-verdict.mjs';
Expand Down Expand Up @@ -208,6 +209,7 @@ const STAGES = new Map(
loopFollowStage,
loopCheckTimeoutStage,
taskObservationStage,
taskIntentStage,
editRecoveryStage,
loopHealthStage,
runTestsVerdictStage,
Expand Down Expand Up @@ -286,6 +288,7 @@ const FAST_GATE = [
'tool-surface',
'image-budget',
'task-ledger-reveal',
'task-intent',
'goal-runs',
'acceptance-blocked',
'goal-resume-args',
Expand Down
30 changes: 30 additions & 0 deletions scripts/verify/stages/task-intent.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import path from 'node:path';
import { captureProcess } from '../lib/proc.mjs';

export const stage = {
name: 'task-intent',
requires: ['build'],
description:
'User corrections update durable state and fence old plans without a second classifier',
async run(context) {
for (const script of [
'task-intent-revisions.mjs',
'task-intent-store.mjs',
'task-revision-probe.mjs',
]) {
const result = await captureProcess(
process.execPath,
[path.join(context.root, 'scripts/verify', script)],
{
cwd: context.root,
env: { ...process.env, MOSS_NO_RDK_DOCS: '1' },
timeoutMs: 30_000,
}
);
if (result.timedOut || result.status !== 0)
return { ok: false, detail: `${script}: ${result.stdout}${result.stderr}` };
console.log(result.stdout.trim());
}
return { ok: true };
},
};
Loading
Loading