@ai-sdk/harness 1.0.92 → 1.0.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @ai-sdk/harness
2
2
 
3
+ ## 1.0.94
4
+
5
+ ### Patch Changes
6
+
7
+ - 8961fde: feat(harness): allow changing `model` between turns via call options
8
+ - eb59f2a: fix(harness): ensure harness adapters can stream tool input deltas before the complete tool call arrives
9
+ - Updated dependencies [55a9981]
10
+ - Updated dependencies [dd32de2]
11
+ - Updated dependencies [aa45741]
12
+ - Updated dependencies [cc29073]
13
+ - ai@7.0.85
14
+ - @ai-sdk/provider@4.0.9
15
+ - @ai-sdk/provider-utils@5.0.34
16
+
17
+ ## 1.0.93
18
+
19
+ ### Patch Changes
20
+
21
+ - cc9f6ce: fix(harness): stop diagnosing caller-initiated aborts as bridge errors, and serialize bridge turns so a start racing an aborted turn's teardown no longer overlaps it (bounded by a teardown grace period, after which the start proceeds as before)
22
+ - 7608210: feat(harness): add `model` parameter to `HarnessAgent` instead of having each harness adapter support it on their own constructor functions
23
+ - 6f8a2d7: fix (harness): ensure the harness bootstrap recipe on resumed sessions too. The marker is keyed by recipe identity, so a resume whose bootstrap is already current costs one file read, while a resume into a sandbox bootstrapped by an older adapter build — a snapshot that outlived the harness version that made it — is re-bootstrapped instead of running a stale bridge against a newer host.
24
+ - 14d4fc0: feat(harness): allow changing harness settings between turns via `prepareCall()` support on `HarnessAgent`
25
+ - Updated dependencies [6669d69]
26
+ - Updated dependencies [a6463ca]
27
+ - Updated dependencies [e604532]
28
+ - Updated dependencies [90192f1]
29
+ - ai@7.0.84
30
+ - @ai-sdk/provider-utils@5.0.33
31
+
3
32
  ## 1.0.92
4
33
 
5
34
  ### Patch Changes
package/README.md CHANGED
@@ -22,6 +22,7 @@ import { z } from 'zod/v4';
22
22
  const agent = new HarnessAgent({
23
23
  harness: claudeCode,
24
24
  id: 'auth-agent',
25
+ model: 'claude-sonnet-4-5',
25
26
  instructions:
26
27
  'You are a careful refactoring assistant. Prefer minimal diffs.',
27
28
  sandbox: createVercelSandbox({
@@ -100,6 +101,9 @@ const agent = new HarnessAgent({
100
101
 
101
102
  Use `session.detach()` to park a bridge-backed session for later attach, `session.stop()` to save state and stop the sandbox, or `session.destroy()` to clean up without keeping resume state. Bridge-backed adapters such as Claude Code, Codex, OpenCode, and DeepAgents require a network sandbox session that exposes ports — `@ai-sdk/sandbox-vercel` is the supported choice today. `@ai-sdk/sandbox-just-bash` is suitable only for host-runtime or otherwise non-bridge flows, such as Pi.
102
103
 
104
+ Set `model` on `HarnessAgent` to select the model used when the harness session
105
+ starts. Model identifiers are harness-specific, so `model` accepts any string.
106
+
103
107
  `sandbox` is an optional `HarnessV1SandboxProvider`. When omitted, pass a `HarnessV1NetworkSandboxSession` to every `agent.createSession({ sandboxSession })` call. Use `sandboxConfig` for agent specific sandbox configuration that works independently from the sandbox provider that is used:
104
108
 
105
109
  - Use `sandboxConfig.onSession` to prepare the acquired sandbox before the harness adapter starts. The hook runs for fresh and resumed sessions, so keep it idempotent.
@@ -126,7 +130,7 @@ See the [harness adapters documentation](https://ai-sdk.dev/v7/docs/ai-sdk-harne
126
130
 
127
131
  ## Implementing a harness
128
132
 
129
- Implement the `HarnessV1` factory and a `HarnessV1Session` whose `doPromptTurn` emits events; the agent surface, streaming, tool execution, and multi-turn state are handled for you. Read `startOpts.sandboxSession` for the selected network sandbox session. The harness layer stops or destroys sessions it acquires from the provider, while a session passed to `agent.createSession({ sandboxSession })` remains caller-owned. Call `sandboxSession.restricted()` for the tool-safe file-IO/exec/spawn surface.
133
+ Implement the `HarnessV1` factory and a `HarnessV1Session` whose `doPromptTurn` emits events; the agent surface, streaming, tool execution, and multi-turn state are handled for you. Read `startOpts.model` for the consumer-selected model and `startOpts.sandboxSession` for the selected network sandbox session. The harness layer stops or destroys sessions it acquires from the provider, while a session passed to `agent.createSession({ sandboxSession })` remains caller-owned. Call `sandboxSession.restricted()` for the tool-safe file-IO/exec/spawn surface.
130
134
 
131
135
  Each prompt and continuation receives an optional `responseFormat`. JSON
132
136
  formats carry a caller-provided JSON Schema plus optional name and description;
@@ -1,8 +1,8 @@
1
1
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
- import { Experimental_SandboxSession, UserModelMessage, ToolSet, FlexibleSchema, Tool, Context, Arrayable, ToolApprovalResponse, ModelMessage } from '@ai-sdk/provider-utils';
3
- import { OutputInterface, StopCondition, ToolApprovalStatus, TelemetryOptions, ActiveTools, StreamTextResult, Agent, AgentCallParameters, GenerateTextResult, AgentStreamParameters, Telemetry } from 'ai';
2
+ import { Experimental_SandboxSession, UserModelMessage, ToolSet, FlexibleSchema, Tool, Context, MaybePromiseLike, Arrayable, ToolApprovalResponse, ModelMessage } from '@ai-sdk/provider-utils';
3
+ import { OutputInterface, AgentCallParameters, Prompt, StopCondition, ToolApprovalStatus, TelemetryOptions, ActiveTools, StreamTextResult, Agent, GenerateTextResult, AgentStreamParameters, Telemetry } from 'ai';
4
4
  import { z } from 'zod/v4';
5
- import { JSONValue, LanguageModelV4ToolCall, LanguageModelV4ToolApprovalRequest, LanguageModelV4ToolResult, LanguageModelV4FinishReason, LanguageModelV4Usage, JSONSchema7, AISDKError } from '@ai-sdk/provider';
5
+ import { JSONSchema7, JSONValue, LanguageModelV4StreamPart, LanguageModelV4ToolCall, LanguageModelV4ToolApprovalRequest, LanguageModelV4ToolResult, LanguageModelV4FinishReason, LanguageModelV4Usage, AISDKError } from '@ai-sdk/provider';
6
6
 
7
7
  /**
8
8
  * One file to write into the sandbox as part of an adapter's bootstrap recipe.
@@ -392,6 +392,66 @@ type HarnessV1ResponseFormat = {
392
392
  readonly description?: string;
393
393
  };
394
394
 
395
+ /**
396
+ * A self-contained instruction bundle the underlying runtime can load into
397
+ * its context. Adapters decide how to surface skills to the runtime.
398
+ */
399
+ type HarnessV1Skill = {
400
+ /** Stable identifier for the skill (kebab-case slug). */
401
+ readonly name: string;
402
+ /**
403
+ * Short, model-facing description. This is what the runtime sees to
404
+ * decide whether the skill is relevant.
405
+ */
406
+ readonly description: string;
407
+ /** Full skill content the model loads when the skill is active. */
408
+ readonly content: string;
409
+ /**
410
+ * Additional files that belong to this skill. Adapters with native skill
411
+ * directories materialize these next to `SKILL.md`; adapters without native
412
+ * skill files include them with the skill content.
413
+ */
414
+ readonly files?: ReadonlyArray<HarnessV1SkillFile>;
415
+ };
416
+ type HarnessV1SkillFile = {
417
+ /**
418
+ * Skill-relative POSIX path, for example `reference.md` or
419
+ * `references/codes.md`. Absolute paths and `..` segments are rejected by
420
+ * adapters before writing.
421
+ */
422
+ readonly path: string;
423
+ /** UTF-8 text content for the file. */
424
+ readonly content: string;
425
+ };
426
+
427
+ /**
428
+ * Description of a host-defined tool that the harness should make available
429
+ * to the underlying agent runtime.
430
+ *
431
+ * Adapters translate this into whatever shape their runtime expects (e.g.
432
+ * Claude Code's tool definitions, Codex CLI's tool config, an MCP server
433
+ * exposed to the runtime, …). The adapter does not execute the tool; when
434
+ * the runtime calls it, the adapter emits a `tool-call` event and waits for
435
+ * `submitToolResult` from the caller.
436
+ */
437
+ type HarnessV1ToolSpec = {
438
+ /**
439
+ * Tool name the agent runtime sees. Must match the name on incoming
440
+ * `tool-call` events.
441
+ */
442
+ readonly name: string;
443
+ /**
444
+ * Human-readable description handed to the runtime, used to help the model
445
+ * decide when to call the tool.
446
+ */
447
+ readonly description?: string;
448
+ /**
449
+ * JSON Schema describing the expected input for the tool. Optional because
450
+ * some runtimes accept tools without schemas (free-form arguments).
451
+ */
452
+ readonly inputSchema?: JSONSchema7;
453
+ };
454
+
395
455
  type HarnessV1PendingToolApproval = {
396
456
  readonly approvalId: string;
397
457
  readonly toolCallId: string;
@@ -406,6 +466,38 @@ type HarnessV1PendingToolResult = {
406
466
  readonly toolName: string;
407
467
  readonly input: string;
408
468
  };
469
+ /**
470
+ * Framework-owned settings captured when a turn begins. The same settings are
471
+ * passed to fresh and continued turns and persisted with unfinished-turn state
472
+ * so a resumed continuation cannot pick up configuration from a later turn.
473
+ */
474
+ type HarnessV1TurnSettings = {
475
+ /**
476
+ * Model identifier selected for this turn. Adapters interpret this value
477
+ * according to the underlying harness runtime. Rerun-based continuations
478
+ * reuse it when reconstructing the turn.
479
+ */
480
+ readonly model?: string;
481
+ /**
482
+ * Skills made available to the underlying runtime for this turn. Adapters
483
+ * must replace skills from the preceding completed turn before starting a
484
+ * fresh turn. Rerun-based continuations use them to reconstruct the turn.
485
+ */
486
+ readonly skills: ReadonlyArray<HarnessV1Skill>;
487
+ /**
488
+ * Free-form instructions for this turn. Adapters should apply them through
489
+ * the runtime's native system or developer instruction mechanism when
490
+ * supported. Rerun-based continuations use them to reconstruct the turn.
491
+ */
492
+ readonly instructions?: string;
493
+ /**
494
+ * Host-defined tools made available to the underlying runtime for this turn.
495
+ * The harness emits `tool-call` events when the runtime calls one and waits
496
+ * for `submitToolResult`. Rerun-based continuations use them to reconstruct
497
+ * the turn.
498
+ */
499
+ readonly tools: ReadonlyArray<HarnessV1ToolSpec>;
500
+ };
409
501
  type HarnessV1LifecycleStateBase = {
410
502
  /**
411
503
  * Identifier of the harness that produced this state. Used by adapters to
@@ -453,40 +545,14 @@ type HarnessV1ContinueTurnState = HarnessV1LifecycleStateBase & {
453
545
  * result before the underlying turn can continue.
454
546
  */
455
547
  readonly pendingToolResults?: readonly HarnessV1PendingToolResult[];
456
- };
457
- type HarnessV1LifecycleState = HarnessV1ResumeSessionState | HarnessV1ContinueTurnState;
458
-
459
- /**
460
- * A self-contained instruction bundle the underlying runtime can load into
461
- * its context. Adapters decide how to surface skills to the runtime.
462
- */
463
- type HarnessV1Skill = {
464
- /** Stable identifier for the skill (kebab-case slug). */
465
- readonly name: string;
466
- /**
467
- * Short, model-facing description. This is what the runtime sees to
468
- * decide whether the skill is relevant.
469
- */
470
- readonly description: string;
471
- /** Full skill content the model loads when the skill is active. */
472
- readonly content: string;
473
548
  /**
474
- * Additional files that belong to this skill. Adapters with native skill
475
- * directories materialize these next to `SKILL.md`; adapters without native
476
- * skill files include them with the skill content.
549
+ * Framework-owned settings captured when the unfinished turn began. They
550
+ * are persisted outside adapter data so a resumed continuation cannot pick
551
+ * up settings prepared for a later turn.
477
552
  */
478
- readonly files?: ReadonlyArray<HarnessV1SkillFile>;
479
- };
480
- type HarnessV1SkillFile = {
481
- /**
482
- * Skill-relative POSIX path, for example `reference.md` or
483
- * `references/codes.md`. Absolute paths and `..` segments are rejected by
484
- * adapters before writing.
485
- */
486
- readonly path: string;
487
- /** UTF-8 text content for the file. */
488
- readonly content: string;
553
+ readonly turnSettings?: HarnessV1TurnSettings;
489
554
  };
555
+ type HarnessV1LifecycleState = HarnessV1ResumeSessionState | HarnessV1ContinueTurnState;
490
556
 
491
557
  /**
492
558
  * Warning emitted by a harness adapter during a call.
@@ -570,7 +636,13 @@ type HarnessV1StreamPart = {
570
636
  type: 'reasoning-end';
571
637
  id: string;
572
638
  harnessMetadata?: HarnessV1Metadata;
573
- } | (LanguageModelV4ToolCall & {
639
+ } | Extract<LanguageModelV4StreamPart, {
640
+ type: 'tool-input-start';
641
+ }> | Extract<LanguageModelV4StreamPart, {
642
+ type: 'tool-input-delta';
643
+ }> | Extract<LanguageModelV4StreamPart, {
644
+ type: 'tool-input-end';
645
+ }> | (LanguageModelV4ToolCall & {
574
646
  nativeName?: string;
575
647
  /**
576
648
  * Total tool calls in the current model step, when known before tool
@@ -607,34 +679,6 @@ type HarnessV1StreamPart = {
607
679
  rawValue: unknown;
608
680
  };
609
681
 
610
- /**
611
- * Description of a host-defined tool that the harness should make available
612
- * to the underlying agent runtime.
613
- *
614
- * Adapters translate this into whatever shape their runtime expects (e.g.
615
- * Claude Code's tool definitions, Codex CLI's tool config, an MCP server
616
- * exposed to the runtime, …). The adapter does not execute the tool; when
617
- * the runtime calls it, the adapter emits a `tool-call` event and waits for
618
- * `submitToolResult` from the caller.
619
- */
620
- type HarnessV1ToolSpec = {
621
- /**
622
- * Tool name the agent runtime sees. Must match the name on incoming
623
- * `tool-call` events.
624
- */
625
- readonly name: string;
626
- /**
627
- * Human-readable description handed to the runtime, used to help the model
628
- * decide when to call the tool.
629
- */
630
- readonly description?: string;
631
- /**
632
- * JSON Schema describing the expected input for the tool. Optional because
633
- * some runtimes accept tools without schemas (free-form arguments).
634
- */
635
- readonly inputSchema?: JSONSchema7;
636
- };
637
-
638
682
  type HarnessV1BuiltinToolFiltering = {
639
683
  mode: 'allow';
640
684
  toolNames: string[];
@@ -657,11 +701,6 @@ type HarnessV1StartOptions = {
657
701
  * (sandbox name, native session id, …).
658
702
  */
659
703
  readonly sessionId: string;
660
- /**
661
- * Skills made available to the underlying runtime for the lifetime of
662
- * the session. Adapters decide how to surface them.
663
- */
664
- readonly skills?: ReadonlyArray<HarnessV1Skill>;
665
704
  /**
666
705
  * Optional resume payload returned by a prior session lifecycle method. When
667
706
  * provided, the adapter should resume the existing session before accepting a
@@ -715,7 +754,7 @@ type HarnessV1StartOptions = {
715
754
  /**
716
755
  * Options passed to `HarnessV1Session.doPromptTurn`.
717
756
  */
718
- type HarnessV1PromptTurnOptions = {
757
+ type HarnessV1PromptTurnOptions = HarnessV1TurnSettings & {
719
758
  /**
720
759
  * Fresh input for this turn — either a plain string or a single
721
760
  * `ModelMessage`. The harness session owns its own conversation history,
@@ -727,20 +766,6 @@ type HarnessV1PromptTurnOptions = {
727
766
  * JSON response format must throw `HarnessCapabilityUnsupportedError`.
728
767
  */
729
768
  readonly responseFormat?: HarnessV1ResponseFormat;
730
- /**
731
- * Host-defined tools to make available to the underlying runtime for this
732
- * turn. The harness emits `tool-call` events when the runtime calls one
733
- * and waits for `submitToolResult`.
734
- */
735
- readonly tools?: ReadonlyArray<HarnessV1ToolSpec>;
736
- /**
737
- * Free-form instructions for the session. The framework supplies the same
738
- * value on every turn. Adapters should append it to the runtime's native
739
- * system or developer prompt when supported. Otherwise, they should prepend
740
- * it to the first user message of a fresh session and rely on the runtime's
741
- * persisted history when resuming.
742
- */
743
- readonly instructions?: string;
744
769
  /**
745
770
  * Signal that aborts the in-flight turn. The adapter must cancel any
746
771
  * underlying work and resolve `done` (with an error if appropriate).
@@ -761,24 +786,12 @@ type HarnessV1PromptTurnOptions = {
761
786
  * in-flight turn rather than starting a new one. It is used to continue a turn
762
787
  * that was previously suspended temporarily, e.g. by the workflow slice loop.
763
788
  */
764
- type HarnessV1ContinueTurnOptions = {
789
+ type HarnessV1ContinueTurnOptions = HarnessV1TurnSettings & {
765
790
  /**
766
791
  * Response format of the in-flight turn. Rerun-based adapters use this when
767
792
  * reconstructing the turn; attach-based adapters may ignore it.
768
793
  */
769
794
  readonly responseFormat?: HarnessV1ResponseFormat;
770
- /**
771
- * Host-defined tools to make available for the continued turn. Same shape
772
- * as `doPromptTurn`'s `tools`. An adapter that purely attaches to a live turn
773
- * may ignore them; an adapter that re-drives the turn (rerun) needs them.
774
- */
775
- readonly tools?: ReadonlyArray<HarnessV1ToolSpec>;
776
- /**
777
- * Free-form session instructions. An adapter that re-drives the runtime may
778
- * need these to reconstruct its native system or developer prompt. An
779
- * adapter that attaches to a live turn may ignore them.
780
- */
781
- readonly instructions?: string;
782
795
  /**
783
796
  * Signal that aborts the continued turn. The adapter must cancel any
784
797
  * underlying work and resolve `done` (with an error if appropriate).
@@ -809,13 +822,6 @@ type HarnessV1Session = {
809
822
  * sessions report `false`; resumed sessions report `true`.
810
823
  */
811
824
  readonly isResume: boolean;
812
- /**
813
- * The model id the underlying runtime is configured to use, if the adapter
814
- * knows it (e.g. from its settings). Surfaced into telemetry as
815
- * `gen_ai.request.model` and the trace span labels. Omitted when the adapter
816
- * defers to the runtime's own default and has no concrete id.
817
- */
818
- readonly modelId?: string;
819
825
  /**
820
826
  * Run one prompt turn. Returns a control handle the host uses to feed
821
827
  * tool results, approvals, and user messages back into the turn while it
@@ -1242,9 +1248,10 @@ type HarnessTools<TOOLS extends ToolSet> = ActiveTools<NoInfer<TOOLS>>;
1242
1248
  /**
1243
1249
  * Construction-time settings for a `HarnessAgent`.
1244
1250
  *
1245
- * Per-call settings (prompt, abortSignal, callbacks) belong on the
1251
+ * Prompt, abortSignal, callbacks, and custom call options belong on the
1246
1252
  * `AgentCallParameters` / `AgentStreamParameters` passed to `generate` /
1247
- * `stream` and are not duplicated here.
1253
+ * `stream`. `prepareCall` can derive turn-scoped model, skills, instructions,
1254
+ * and tools from those custom call options.
1248
1255
  */
1249
1256
  type HarnessAgentToolFilteringSettings<TOOLS extends ToolSet> = {
1250
1257
  /**
@@ -1261,7 +1268,7 @@ type HarnessAgentToolFilteringSettings<TOOLS extends ToolSet> = {
1261
1268
  */
1262
1269
  readonly inactiveTools?: HarnessTools<TOOLS>;
1263
1270
  };
1264
- type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never> = {
1271
+ type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never, CALL_OPTIONS = never> = {
1265
1272
  /**
1266
1273
  * The harness adapter driving the underlying agent runtime. Its
1267
1274
  * `builtinTools` are merged with the user-defined `tools` and exposed to
@@ -1273,6 +1280,12 @@ type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAge
1273
1280
  * If omitted, `agent.id` is `undefined`.
1274
1281
  */
1275
1282
  readonly id?: string;
1283
+ /**
1284
+ * Model identifier used by the harness adapter. Supported values are
1285
+ * defined by the selected harness. `prepareCall` can replace it between
1286
+ * completed turns.
1287
+ */
1288
+ readonly model?: string;
1276
1289
  /**
1277
1290
  * Tools available to the underlying runtime in addition to the harness's
1278
1291
  * own builtins. The agent forwards each tool to the harness as a
@@ -1284,17 +1297,37 @@ type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAge
1284
1297
  */
1285
1298
  readonly tools?: TUserTools;
1286
1299
  /**
1287
- * Skills made available to the underlying runtime for the lifetime of
1288
- * the session. Each adapter decides how to surface skills (file in the
1289
- * working tree, prompt prefix, …).
1300
+ * Skills made available to the underlying runtime. Each adapter decides how
1301
+ * to surface skills. `prepareCall` can replace them between completed turns.
1290
1302
  */
1291
1303
  readonly skills?: ReadonlyArray<HarnessAgentSkill>;
1292
1304
  /**
1293
- * Instructions for the underlying agent runtime. Adapters append this to a
1305
+ * Instructions for the underlying agent runtime. Adapters append these to a
1294
1306
  * native system or developer prompt when supported. Otherwise, they prepend
1295
- * it to the first user message of a fresh session.
1307
+ * them to the user message. `prepareCall` can replace them between completed
1308
+ * turns.
1296
1309
  */
1297
1310
  readonly instructions?: string;
1311
+ /**
1312
+ * Schema for validating the custom options passed to each agent call.
1313
+ */
1314
+ readonly callOptionsSchema?: FlexibleSchema<CALL_OPTIONS>;
1315
+ /**
1316
+ * Prepares the prompt and the settings that may vary between completed
1317
+ * turns. The prepared values are frozen for the lifetime of the turn,
1318
+ * including any suspended-turn continuations.
1319
+ *
1320
+ * Preserve the remaining arguments with the rest-spread pattern when a
1321
+ * field should be removable by returning `undefined`:
1322
+ *
1323
+ * ```ts
1324
+ * prepareCall: ({ options, ...rest }) => ({
1325
+ * ...rest,
1326
+ * instructions: options.instructions,
1327
+ * })
1328
+ * ```
1329
+ */
1330
+ readonly prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT>, 'abortSignal' | 'timeout' | 'onStart' | 'experimental_onStart' | 'onStepStart' | 'experimental_onStepStart' | 'onToolExecutionStart' | 'experimental_onToolCallStart' | 'onToolExecutionEnd' | 'experimental_onToolCallFinish' | 'onStepEnd' | 'onStepFinish' | 'onEnd' | 'onFinish' | 'experimental_sandbox'> & Pick<HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, NoInfer<OUTPUT>, CALL_OPTIONS>, 'model' | 'skills' | 'instructions' | 'tools'>) => MaybePromiseLike<Pick<HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, NoInfer<OUTPUT>, CALL_OPTIONS>, 'model' | 'skills' | 'instructions' | 'tools'> & Omit<Prompt, 'system' | 'instructions' | 'allowSystemInMessages'>>;
1298
1331
  /**
1299
1332
  * Optional specification for generating typed output. The same output
1300
1333
  * requirement is active for every turn run by this agent.
@@ -1399,6 +1432,7 @@ declare function collectHarnessAgentToolResultContinuations(input: {
1399
1432
  type HarnessAgentTurnResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface> = {
1400
1433
  result: StreamTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1401
1434
  done: Promise<void>;
1435
+ ready: Promise<void>;
1402
1436
  };
1403
1437
  type HarnessAgentTurnState = 'idle' | 'running' | 'awaiting-approval' | 'awaiting-tool-result' | 'suspended';
1404
1438
  /**
@@ -1434,6 +1468,8 @@ declare class HarnessAgentSession {
1434
1468
  private activeTurnSequence;
1435
1469
  private activePromptControl;
1436
1470
  private suspendedTurnState;
1471
+ private activeTurnSettings;
1472
+ private persistedTurnSettings;
1437
1473
  /**
1438
1474
  * Whether this session was created from `resumeFrom` or `continueFrom`.
1439
1475
  * Captured at construction so it survives lifecycle cleanup.
@@ -1449,11 +1485,14 @@ declare class HarnessAgentSession {
1449
1485
  toolApproval: HarnessAgentToolApprovalConfiguration | undefined;
1450
1486
  pendingToolApprovals?: readonly HarnessAgentPendingToolApproval[];
1451
1487
  pendingToolResults?: readonly HarnessAgentPendingToolResult[];
1488
+ turnSettings?: HarnessV1TurnSettings;
1452
1489
  turnState?: HarnessAgentTurnState;
1453
1490
  });
1454
1491
  hasUnfinishedTurn(): boolean;
1455
1492
  promptTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
1456
1493
  prompt: HarnessAgentPrompt;
1494
+ model: string | undefined;
1495
+ skills: ReadonlyArray<HarnessV1Skill>;
1457
1496
  instructions: string | undefined;
1458
1497
  tools: TOOLS;
1459
1498
  activeTools: ToolSet;
@@ -1467,6 +1506,8 @@ declare class HarnessAgentSession {
1467
1506
  stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
1468
1507
  }): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1469
1508
  continueTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
1509
+ model: string | undefined;
1510
+ skills: ReadonlyArray<HarnessV1Skill>;
1470
1511
  instructions: string | undefined;
1471
1512
  tools: TOOLS;
1472
1513
  activeTools: ToolSet;
@@ -1543,9 +1584,11 @@ declare class HarnessAgentSession {
1543
1584
  private markAwaitingToolResultIfActive;
1544
1585
  private startTrackedTurn;
1545
1586
  private setPromptControl;
1587
+ private waitForPromptControl;
1546
1588
  private settleActivePromptControl;
1547
1589
  private clearActivePromptControl;
1548
1590
  private finishTrackedTurn;
1591
+ private resolveActiveTurnSettings;
1549
1592
  private endLocalHandle;
1550
1593
  private requireReusableSession;
1551
1594
  }
@@ -1598,7 +1641,7 @@ interface HarnessAgentCallExtensions {
1598
1641
  * remain owned by the caller and are not stopped or destroyed by the
1599
1642
  * harness layer.
1600
1643
  */
1601
- declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never> implements Agent<never, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT> {
1644
+ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never, CALL_OPTIONS = never> implements Agent<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT> {
1602
1645
  readonly version: "agent-v1";
1603
1646
  readonly id: string | undefined;
1604
1647
  /**
@@ -1611,10 +1654,9 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
1611
1654
  private readonly settings;
1612
1655
  private readonly stopConditions;
1613
1656
  private readonly sandboxConfig;
1614
- private readonly activeUserTools;
1615
1657
  private readonly builtinToolFiltering;
1616
1658
  private readonly permissionMode;
1617
- constructor(settings: HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, OUTPUT>);
1659
+ constructor(settings: HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, OUTPUT, CALL_OPTIONS>);
1618
1660
  /** Identifier of the harness backing this agent. */
1619
1661
  get harnessId(): string;
1620
1662
  /**
@@ -1652,8 +1694,8 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
1652
1694
  sandboxSession?: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
1653
1695
  abortSignal?: AbortSignal;
1654
1696
  }): Promise<HarnessAgentSession>;
1655
- generate(options: AgentCallParameters<never, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1656
- stream(options: AgentStreamParameters<never, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1697
+ generate(options: AgentCallParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1698
+ stream(options: AgentStreamParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1657
1699
  /**
1658
1700
  * Continue the in-flight turn **without a new prompt**, draining it like
1659
1701
  * {@link generate}. Used after `createSession({ continueFrom })` to finish
@@ -1690,8 +1732,14 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
1690
1732
  session: HarnessAgentSession;
1691
1733
  text: string;
1692
1734
  }): Promise<void>;
1693
- private _startTurn;
1694
- private _resolveTurnInput;
1735
+ private _startPromptTurn;
1736
+ private _startContinueTurn;
1737
+ private _buildTurnOptions;
1738
+ private _resolveContinueTurnInput;
1739
+ private _resolvePromptTurnInput;
1740
+ private _preparePromptTurnInput;
1741
+ private _prepareContinueTurnInput;
1742
+ private _prepareTurnSettings;
1695
1743
  private _toToolSpecs;
1696
1744
  private _toGenerateResult;
1697
1745
  private _resolveResponseFormat;