Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1f13f7f
feat(task): revise effective goals and fence superseded execution
Nov 19, 2026
6fc0805
fix(task): preserve completed history and fence older active tasks
Nov 19, 2026
1d8a4df
feat(intent): commit user corrections and invalidate superseded plans
Nov 19, 2026
9106677
fix(intent): keep follow-up native task binding host-owned
Nov 19, 2026
3a83141
feat(context): preserve sources and fence stale execution
Nov 21, 2026
185c2ba
fix(sdk): restore opt-in Studio diagnostics adapter
Nov 21, 2026
0d5204d
fix(context): bind corrections and rebuild cited checkpoints
Nov 21, 2026
97c237a
fix(context): make applied corrections safe to replay
Nov 21, 2026
b075a70
fix(context): isolate read-only claim validation from receipts
Nov 21, 2026
8f0b7b6
perf(context): trim read-only intent requests
Nov 21, 2026
282a184
perf(context): keep read-only decisions focused on answers and correc…
Nov 21, 2026
985d3b0
perf(context): bind compact correction references to original sources
Nov 21, 2026
2cc7151
fix(context): bound historical tool payloads and persist scoped corre…
Nov 22, 2026
5c09ba6
fix(context): keep recent tool evidence across compacted checkpoints
Nov 22, 2026
b558cfe
fix(context): distinguish superseded conclusions from later evidence
Nov 22, 2026
f142953
perf(context): rebuild corrected summaries off the reply path
Nov 22, 2026
acafddb
fix(context): submit read-only decisions with MiniMax structured output
Nov 22, 2026
514d745
fix(context): constrain corrected follow-ups on MiniMax buffered API
Nov 22, 2026
1ace29d
fix(context): bound cited summaries and recover from invalid citations
Nov 22, 2026
6db1489
fix(context): retain task-relevant diagnostics in summary inputs
Nov 22, 2026
91fb82d
fix(context): recover focused tool receipts when reusing checkpoints
Nov 22, 2026
f926abf
fix(context): keep observations tied to one source and operation
Nov 22, 2026
d84f095
Retain run-scoped artifact receipts during compaction
Nov 22, 2026
707483c
Merge versioned context compression and summary recovery
Nov 22, 2026
74e8640
style: format context merge for the verification gate
Nov 22, 2026
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
67 changes: 67 additions & 0 deletions docs/sdk-task-intent-revisions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# 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.

## Versioned context

Set `MOSS_VERSIONED_CONTEXT=1` for a CLI workspace, or supply
`new VersionedSessionStore(databasePath, legacyStore)` together with
`taskIntent: true` when embedding. Once initialized, the CLI reopens the same
database on later launches. The store is scoped by the host's account and session
identity. Close the agent before closing a store owned by the host.

- `/context sources` lists original message IDs, and `/context claims` shows
recorded conclusions and their status.
- `/context correct <id> <text>` records a correction to an assistant message or
claim. `MossAgent.correctContext(sessionKey, { id, targetId, text })` is the
idempotent SDK equivalent.
- `/compact` prepares or selects a source-checked checkpoint. It preserves
original source rows. `MossAgent.listContextSources` can inspect them after
a restart. Imported sessions can only retain messages still present on disk.

The request pipeline progressively adjusts the output reservation, shortens old
tool results, prepares checkpoints in the background, reuses compatible
checkpoints, or performs bounded synchronous summarization. Provider-independent
admission uses a conservative serialized-size estimate. Provider-reported
overflow triggers a bounded retry with a smaller budget. Structured summaries
are historical data, and do not authorize work or commit acceptance.

On correction, the store invalidates dependent claims and supersedes all prior
checkpoint revisions. Legacy unstructured replies in the affected range are
excluded from the model view conservatively. In-flight provider responses and
business tool dispatch check their captured version. Tools already started can
have side effects. After an uncertain interruption their invocation record
remains unsettled. Use `/context unsettled` to inspect these records. After
checking the external state, record the observed outcome with
`/context reconcile <invocation-id> <observed outcome>` to resume mutations.

Run `node scripts/verify/cli.mjs --stage versioned-context,task-intent` for the
scripted provider and restart probes.
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
5 changes: 5 additions & 0 deletions scripts/verify/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ 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 versionedContextStage } from './stages/versioned-context.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 +210,8 @@ const STAGES = new Map(
loopFollowStage,
loopCheckTimeoutStage,
taskObservationStage,
taskIntentStage,
versionedContextStage,
editRecoveryStage,
loopHealthStage,
runTestsVerdictStage,
Expand Down Expand Up @@ -286,6 +290,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 };
},
};
25 changes: 25 additions & 0 deletions scripts/verify/stages/versioned-context.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import path from 'node:path';
import { captureProcess } from '../lib/proc.mjs';

export const stage = {
name: 'versioned-context',
requires: ['build'],
description:
'Durable context corrections fence old checkpoints, actions and verdicts across restart',
async run(context) {
const result = await captureProcess(
process.execPath,
[path.join(context.root, 'scripts/verify/versioned-context.mjs')],
{
cwd: context.root,
env: { ...process.env, MOSS_NO_RDK_DOCS: '1' },
timeoutMs: 45_000,
}
);
if (result.timedOut || result.status !== 0) {
return { ok: false, detail: `${result.stdout}${result.stderr}` };
}
console.log(result.stdout.trim());
return { ok: true };
},
};
Loading
Loading