@yielded/agent 0.1.0-beta.174 → 0.1.0-beta.175
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/dist/{Admin-BHmp2V9p.d.mts → Admin-Qa3I1oA5.d.mts} +38 -7
- package/dist/{AgentRuntime-BD3ZHAMq.d.mts → AgentRuntime-CHDyRbSf.d.mts} +3 -3
- package/dist/{AgentRuntime-B6qZlD3f.mjs → AgentRuntime-DaDKMasp.mjs} +123 -114
- package/dist/AgentRuntime-DaDKMasp.mjs.map +1 -0
- package/dist/{Digest-EpeqWEdv.mjs → Digest-C3EODOee.mjs} +2 -2
- package/dist/{Digest-EpeqWEdv.mjs.map → Digest-C3EODOee.mjs.map} +1 -1
- package/dist/{DurableAgentRuntime-CBBjRNJN.mjs → DurableAgentRuntime-CPlw5_7e.mjs} +161 -85
- package/dist/DurableAgentRuntime-CPlw5_7e.mjs.map +1 -0
- package/dist/{EventSource-C9aaJaXT.d.mts → EventSource-BTu68yDW.d.mts} +2 -2
- package/dist/InMemory.d.mts +2 -2
- package/dist/{MessageDelivery-BGDm-c46.d.mts → MessageDelivery-DjAZJ4Fd.d.mts} +4 -4
- package/dist/{MessagingHost-CRUK4JBi.mjs → MessagingHost-CZCyrnvJ.mjs} +27 -26
- package/dist/MessagingHost-CZCyrnvJ.mjs.map +1 -0
- package/dist/{PreparedInputAdmission-BvDqlgiP.d.mts → PreparedInputAdmission-wgY4JMZY.d.mts} +3 -3
- package/dist/{Records-BiuJDWNe.mjs → Records-DzL4Kbtw.mjs} +2 -2
- package/dist/{Records-BiuJDWNe.mjs.map → Records-DzL4Kbtw.mjs.map} +1 -1
- package/dist/{RunContinuation-CTJ1jGrO.d.mts → RunContinuation-3jB5pULC.d.mts} +10 -4
- package/dist/{RunContinuation-4ZATcVLB.mjs → RunContinuation-BiyKJK32.mjs} +74 -40
- package/dist/RunContinuation-BiyKJK32.mjs.map +1 -0
- package/dist/{RunJournal-CNZqA3Ge.mjs → RunJournal-CPMKcfd0.mjs} +84 -79
- package/dist/RunJournal-CPMKcfd0.mjs.map +1 -0
- package/dist/{RunStorage-BHjuuERI.mjs → RunStorage-CzutHJBE.mjs} +3 -2
- package/dist/RunStorage-CzutHJBE.mjs.map +1 -0
- package/dist/{Scheduling-NG8slKdI.mjs → Scheduling-07_dsGED.mjs} +3 -3
- package/dist/{Scheduling-NG8slKdI.mjs.map → Scheduling-07_dsGED.mjs.map} +1 -1
- package/dist/{Subagent-CTIpnzlB.mjs → Subagent-CexndZSp.mjs} +2 -2
- package/dist/{Subagent-CTIpnzlB.mjs.map → Subagent-CexndZSp.mjs.map} +1 -1
- package/dist/{Subagent-DKhZA72u.d.mts → Subagent-xhN_aD1r.d.mts} +3 -3
- package/dist/{Subscription-BNg9VCRl.d.mts → Subscription-DmIHlOJK.d.mts} +2 -2
- package/dist/{SubscriptionInput-BUoXv-_K.d.mts → SubscriptionInput-DgcQhvbe.d.mts} +2 -2
- package/dist/{Thread-dk-QiNml.d.mts → Thread-DzdJAY4J.d.mts} +4 -3
- package/dist/{ThreadHistory-ByxS8HU1.d.mts → ThreadHistory-KPPBJLJb.d.mts} +12 -2
- package/dist/{ThreadImport-CodYoJoa.mjs → ThreadImport-CjlG57vH.mjs} +8 -8
- package/dist/{ThreadImport-CodYoJoa.mjs.map → ThreadImport-CjlG57vH.mjs.map} +1 -1
- package/dist/{ThreadImport-CMgzttvr.d.mts → ThreadImport-DP-vOk2F.d.mts} +4 -4
- package/dist/{ThreadStore-59uDGXul.mjs → ThreadStore-EuUilthA.mjs} +5 -7
- package/dist/ThreadStore-EuUilthA.mjs.map +1 -0
- package/dist/{ThreadTransfer-3jigUl3g.mjs → ThreadTransfer-DB_zsrtJ.mjs} +4 -4
- package/dist/{ThreadTransfer-3jigUl3g.mjs.map → ThreadTransfer-DB_zsrtJ.mjs.map} +1 -1
- package/dist/{WorkerAdmission-DDYJdOsU.mjs → WorkerAdmission-eBeXt_mu.mjs} +5 -5
- package/dist/{WorkerAdmission-DDYJdOsU.mjs.map → WorkerAdmission-eBeXt_mu.mjs.map} +1 -1
- package/dist/{agent-registration-DRbyhAu-.mjs → agent-registration-a6QYaG3h.mjs} +4 -4
- package/dist/{agent-registration-DRbyhAu-.mjs.map → agent-registration-a6QYaG3h.mjs.map} +1 -1
- package/dist/capabilities/Messaging.mjs +1 -1
- package/dist/capabilities/ModelContext.d.mts +1 -1
- package/dist/capabilities/RunHooks.d.mts +1 -1
- package/dist/capabilities/Subagent.d.mts +1 -1
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/core/Thread.d.mts +2 -2
- package/dist/core/Thread.mjs +5 -3
- package/dist/core/Thread.mjs.map +1 -1
- package/dist/durable/ActivityStore.mjs +1 -1
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/Admin.mjs +1 -1
- package/dist/durable/AgentRegistration.d.mts +1 -1
- package/dist/durable/AgentRegistration.mjs +1 -1
- package/dist/durable/Certification.d.mts +1 -1
- package/dist/durable/CommittedActivity.d.mts +1 -1
- package/dist/durable/CommittedActivity.mjs +3 -3
- package/dist/durable/Digest.mjs +1 -1
- package/dist/durable/DurableAgentRuntime.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +2 -2
- package/dist/durable/EventSource.d.mts +1 -1
- package/dist/durable/EventSource.mjs +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/LifecyclePublication.d.mts +1 -1
- package/dist/durable/LifecyclePublication.mjs +2 -2
- package/dist/durable/MessageDelivery.d.mts +1 -1
- package/dist/durable/MessageDelivery.mjs +2 -2
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +40 -40
- package/dist/durable/MessageDeliveryStoreConformance.mjs +2 -2
- package/dist/durable/PersistentHistory.d.mts +2 -2
- package/dist/durable/PersistentHistory.mjs +4 -4
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/RecordFormat.mjs +1 -1
- package/dist/durable/Records.mjs +1 -1
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/Recovery.mjs +1 -1
- package/dist/durable/RunContinuation.d.mts +2 -2
- package/dist/durable/RunContinuation.mjs +3 -3
- package/dist/durable/RunJournal.d.mts +2 -2
- package/dist/durable/RunJournal.mjs +2 -2
- package/dist/durable/RunStorage.d.mts +1 -1
- package/dist/durable/RunStorage.mjs +1 -1
- package/dist/durable/Schedule.mjs +1 -1
- package/dist/durable/ScheduleStoreConformance.mjs +1 -1
- package/dist/durable/ScheduleTransition.mjs +1 -1
- package/dist/durable/Scheduling.d.mts +1 -1
- package/dist/durable/Scheduling.mjs +1 -1
- package/dist/durable/SettlementPublisher.d.mts +1 -1
- package/dist/durable/SettlementPublisher.mjs +3 -3
- package/dist/durable/SqlMemoryStore.mjs +5 -3
- package/dist/durable/SqlMemoryStore.mjs.map +1 -1
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedger.mjs +7 -3
- package/dist/durable/SubmissionLedger.mjs.map +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.mjs +6 -6
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/Subscription.mjs +2 -2
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionInput.mjs +2 -2
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
- package/dist/durable/SubscriptionTools.d.mts +2 -2
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/SubscriptionTransition.mjs +1 -1
- package/dist/durable/Subscriptions.d.mts +5 -5
- package/dist/durable/Subscriptions.mjs +2 -2
- package/dist/durable/ThreadArchiveRange.d.mts +1 -1
- package/dist/durable/ThreadArchiveRange.mjs +1 -1
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistory.mjs +2 -2
- package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
- package/dist/durable/ThreadImport.d.mts +1 -1
- package/dist/durable/ThreadImport.mjs +1 -1
- package/dist/durable/ThreadInvariants.d.mts +3 -3
- package/dist/durable/ThreadInvariants.mjs +4 -4
- package/dist/durable/ThreadProjection.mjs +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadReader.d.mts +1 -1
- package/dist/durable/ThreadReader.mjs +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStore.mjs +2 -2
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.mjs +4 -4
- package/dist/durable/ThreadTransfer.d.mts +1 -1
- package/dist/durable/ThreadTransfer.mjs +1 -1
- package/dist/durable/ThreadWork.d.mts +2 -2
- package/dist/durable/ThreadWork.mjs +12 -6
- package/dist/durable/ThreadWork.mjs.map +1 -1
- package/dist/durable/ToolReconciler.mjs +1 -1
- package/dist/durable/WakeScheduler.mjs +23 -39
- package/dist/durable/WakeScheduler.mjs.map +1 -1
- package/dist/durable/WorkerAdmission.d.mts +1 -1
- package/dist/durable/WorkerAdmission.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +1 -1
- package/dist/engine/AgentRuntime.d.mts +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/engine/MessagingHost.mjs +1 -1
- package/dist/engine/Output.mjs +1 -1
- package/dist/engine/ThreadHistory.d.mts +1 -1
- package/dist/engine/ThreadHistory.mjs +3 -2
- package/dist/engine/ThreadHistory.mjs.map +1 -1
- package/dist/index.d.mts +12 -12
- package/dist/index.mjs +13 -13
- package/dist/{output-contract-CMIhu4Cw.mjs → output-contract-DCnLYCdp.mjs} +12 -15
- package/dist/{output-contract-CMIhu4Cw.mjs.map → output-contract-DCnLYCdp.mjs.map} +1 -1
- package/dist/{run-context-reader-CC7ZD95F.d.mts → run-context-reader-DVhJZ1Qe.d.mts} +2 -2
- package/package.json +1 -1
- package/src/core/Thread.ts +143 -146
- package/src/durable/DurableAgentRuntime.ts +381 -206
- package/src/durable/RunContinuation.ts +113 -62
- package/src/durable/RunJournal.ts +99 -108
- package/src/durable/RunStorage.ts +7 -0
- package/src/durable/SqlMemoryStore.ts +8 -6
- package/src/durable/SubmissionLedger.ts +7 -0
- package/src/durable/ThreadStore.ts +9 -7
- package/src/durable/ThreadWork.ts +10 -0
- package/src/durable/WakeScheduler.ts +34 -66
- package/src/durable/internal/usage-totals.ts +28 -31
- package/src/engine/MessagingHost.ts +4 -2
- package/src/engine/ThreadHistory.ts +47 -48
- package/src/engine/internal/agent-runtime.ts +234 -202
- package/src/engine/internal/output-contract.ts +15 -15
- package/src/engine/internal/primitive-delta.ts +2 -3
- package/src/engine/internal/tool-telemetry.ts +3 -5
- package/dist/AgentRuntime-B6qZlD3f.mjs.map +0 -1
- package/dist/DurableAgentRuntime-CBBjRNJN.mjs.map +0 -1
- package/dist/MessagingHost-CRUK4JBi.mjs.map +0 -1
- package/dist/RunContinuation-4ZATcVLB.mjs.map +0 -1
- package/dist/RunJournal-CNZqA3Ge.mjs.map +0 -1
- package/dist/RunStorage-BHjuuERI.mjs.map +0 -1
- package/dist/ThreadStore-59uDGXul.mjs.map +0 -1
|
@@ -13,11 +13,11 @@ import { a as PinnedTool, c as ToolNames, i as Limits, l as ToolNamespace, n as
|
|
|
13
13
|
import { InputTokenUsage, ModelCallUsage, ModelResponseIdentity, OutputTokenUsage, RunTotals, RunUsageReport, emptyRunTotals, sumRunTotals, unknownRunTotals } from "./core/Usage.mjs";
|
|
14
14
|
import { AgentUpdateEmitted, ApprovalRequested, BudgetWarning, CompactionPerformed, ModelRestarted, ModelStarted, ReasoningDelta, RunCompleted, RunFailed, RunStarted, RunSuspended, SubagentCompleted, SubagentFailed, SubagentInterrupted, SubagentJoined, SubagentProgress, SubagentRequested, SubagentStarted, TextDelta, ToolCallDeclared, ToolCallFailed, ToolCallStarted, ToolCallSucceeded, ToolProgress, TurnCompleted, TurnStarted } from "./core/RunEvent.mjs";
|
|
15
15
|
import { r as FrameworkMessage, t as AssignmentDisposition } from "./Worker-DZjdMjZn.mjs";
|
|
16
|
-
import { t as MessagingHost } from "./MessagingHost-
|
|
16
|
+
import { t as MessagingHost } from "./MessagingHost-CZCyrnvJ.mjs";
|
|
17
17
|
import { SubagentHost } from "./engine/SubagentHost.mjs";
|
|
18
18
|
import { ThreadHistory, ThreadHistoryError } from "./engine/ThreadHistory.mjs";
|
|
19
19
|
import { n as RunToolVisibility, t as CurrentToolCatalog } from "./ToolExposure-DBATXxmL.mjs";
|
|
20
|
-
import { n as outputSchemaContract, r as prepareModelPrompt, t as isTextOutput } from "./output-contract-
|
|
20
|
+
import { n as outputSchemaContract, r as prepareModelPrompt, t as isTextOutput } from "./output-contract-DCnLYCdp.mjs";
|
|
21
21
|
import { _ as initialCompactionState, b as boundedCanonicalJsonSnapshot, d as collectCoveredMessages, f as contextWindowId, g as evaluateMessageTokenEstimates, h as estimatePromptTokens, m as estimateMessageTokens, s as buildCompactedView, v as isContextOverflowMessage, x as boundedJsonSnapshot } from "./compaction-CgFMDiXL.mjs";
|
|
22
22
|
import { Publisher, noopPublisher } from "./core/ProvisionalText.mjs";
|
|
23
23
|
import { ContextRolloverRequest, ContextRolloverSelection, ContextRolloverTool, ContextWindow, ContextWindowStatus, ModelCallContext } from "./engine/ContextWindow.mjs";
|
|
@@ -301,7 +301,7 @@ const overheads = {
|
|
|
301
301
|
"reasoning-end": boundaryOverhead("reasoning-end")
|
|
302
302
|
};
|
|
303
303
|
/**
|
|
304
|
-
* Capture primitive text and reasoning
|
|
304
|
+
* Capture complete primitive text and reasoning values for native Schema validation.
|
|
305
305
|
* Descriptor checks select this optimization; they do not replace the native codec.
|
|
306
306
|
* Extra fields, accessors, and nonempty metadata use the general ownership path.
|
|
307
307
|
* No provider object survives, including an empty metadata object's hidden storage.
|
|
@@ -339,9 +339,8 @@ const capturePrimitiveTextPart = (part, maxBytes) => {
|
|
|
339
339
|
const bytes = utf8ByteLength(id) + (typeof delta === "string" ? utf8ByteLength(delta) : 0);
|
|
340
340
|
if (bytes + fixed.source > maxBytes || bytes + fixed.encoded > maxBytes) return void 0;
|
|
341
341
|
snapshot.metadata = {};
|
|
342
|
-
delete snapshot[brand];
|
|
343
342
|
return {
|
|
344
|
-
|
|
343
|
+
part: snapshot,
|
|
345
344
|
retainedBytes: bytes + fixed.encoded
|
|
346
345
|
};
|
|
347
346
|
} catch {
|
|
@@ -800,7 +799,7 @@ const makeIsolatedToolTracer = (delegate) => {
|
|
|
800
799
|
* decorating, or locally providing a Tracer implementation.
|
|
801
800
|
*/
|
|
802
801
|
var ToolSpanTelemetry = class ToolSpanTelemetry extends Context.Service()("@effect-agent/engine/ToolSpanTelemetry") {
|
|
803
|
-
static
|
|
802
|
+
static make = Effect.map(Tracer.Tracer, (delegate) => ToolSpanTelemetry.of({
|
|
804
803
|
isolateEffectSpanLifecycle: (effect) => Effect.suspend(() => {
|
|
805
804
|
const isolated = makeIsolatedToolTracer(delegate);
|
|
806
805
|
return effect.pipe(Effect.provideService(Tracer.Tracer, isolated.tracer), Effect.ensuring(isolated.reportLifecycleDefects));
|
|
@@ -825,7 +824,7 @@ var ToolSpanTelemetry = class ToolSpanTelemetry extends Context.Service()("@effe
|
|
|
825
824
|
const isolated = makeIsolatedToolTracer(delegate);
|
|
826
825
|
return stream.pipe(Stream.provideService(Tracer.Tracer, isolated.tracer), Stream.ensuring(isolated.reportLifecycleDefects));
|
|
827
826
|
}))
|
|
828
|
-
}))
|
|
827
|
+
}));
|
|
829
828
|
};
|
|
830
829
|
//#endregion
|
|
831
830
|
//#region src/engine/internal/error-diagnostic.ts
|
|
@@ -917,20 +916,20 @@ const toolCounter = Metric.counter("effect_agent_tool_calls_total", { descriptio
|
|
|
917
916
|
/** Publish from the Turn owner; failed storage acceptance is never retried by failure cleanup. */
|
|
918
917
|
const acceptTurnCommit = (context, trace, durability, commit) => Effect.suspend(() => {
|
|
919
918
|
if (trace.commitFailed) return Effect.void;
|
|
920
|
-
|
|
919
|
+
const accepted = checkpointExecution(context, durability).pipe(Effect.andThen(() => durability?.commitTurn(commit) ?? Effect.succeed("committed")));
|
|
920
|
+
return Effect.onExitPrimitive(Effect.flatMap(accepted, (receipt) => {
|
|
921
921
|
if (receipt === "deferred") return commit._tag === "Response" && commit.defer === true ? Effect.void : Effect.fail(ModelProtocolError.make({ message: "Durability deferred an ineligible Turn commit" }));
|
|
922
|
-
|
|
923
|
-
if (commit.
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
trace.responseCommitted = true;
|
|
927
|
-
}
|
|
928
|
-
if (commit._tag === "Settled") trace.resultsCommitted = true;
|
|
922
|
+
if (commit._tag !== "Partial") {
|
|
923
|
+
if (commit.response !== void 0) {
|
|
924
|
+
context.pendingCommitInputs.splice(0, trace.commitInputCount ?? 0);
|
|
925
|
+
trace.responseCommitted = true;
|
|
929
926
|
}
|
|
930
|
-
|
|
931
|
-
|
|
927
|
+
if (commit._tag === "Settled") trace.resultsCommitted = true;
|
|
928
|
+
}
|
|
929
|
+
return Effect.void;
|
|
930
|
+
}), (exit) => {
|
|
932
931
|
if (Exit.isFailure(exit)) trace.commitFailed = true;
|
|
933
|
-
})
|
|
932
|
+
});
|
|
934
933
|
});
|
|
935
934
|
/** Only stream-closed application outcomes enter the trace; provider results stay in response. */
|
|
936
935
|
const turnToolResults = (trace) => Effect.forEach(trace.applicationToolResults.filter((result) => result !== void 0), (result) => Effect.map(decodeToolCallId(result.id), (toolCallId) => ({
|
|
@@ -1086,18 +1085,32 @@ const captureModelResponsePartGeneral = Effect.fnUntraced(function* (part, toolk
|
|
|
1086
1085
|
retainedBytes
|
|
1087
1086
|
};
|
|
1088
1087
|
});
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1088
|
+
const decodePrimitiveModelResponsePart = Schema.decodeUnknownEffect(Schema.toType(Schema.Union([
|
|
1089
|
+
Response.TextStartPart,
|
|
1090
|
+
Response.TextDeltaPart,
|
|
1091
|
+
Response.TextEndPart,
|
|
1092
|
+
Response.ReasoningStartPart,
|
|
1093
|
+
Response.ReasoningDeltaPart,
|
|
1094
|
+
Response.ReasoningEndPart
|
|
1095
|
+
])));
|
|
1093
1096
|
/** Reject trailing content before its capture can run an application codec or suspend. */
|
|
1094
|
-
const ownModelResponsePart =
|
|
1095
|
-
if (finished) return
|
|
1096
|
-
const
|
|
1097
|
-
return {
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1097
|
+
const ownModelResponsePart = (part, toolkit, usage, limits, finished) => Effect.suspend(() => {
|
|
1098
|
+
if (finished) return Effect.fail(ModelProtocolError.make({ message: "Model response emitted content after its finish part" }));
|
|
1099
|
+
const primitive = usage.responsePartCount < limits.maxModelResponseParts ? capturePrimitiveTextPart(part, limits.maxModelResponseBytes - usage.responsePartBytes) : void 0;
|
|
1100
|
+
if (primitive !== void 0) return Effect.mapBothEager(decodePrimitiveModelResponsePart(primitive.part), {
|
|
1101
|
+
onFailure: () => ModelProtocolError.make({ message: "Model response part failed canonical decoding" }),
|
|
1102
|
+
onSuccess: (ownedPart) => ({
|
|
1103
|
+
ownedPart,
|
|
1104
|
+
retainedBytes: primitive.retainedBytes
|
|
1105
|
+
})
|
|
1106
|
+
});
|
|
1107
|
+
return Effect.flatMapEager(captureModelResponsePartGeneral(part, toolkit, usage, limits), (captured) => Effect.mapBothEager(modelResponseParsersFor(toolkit).decode(captured.encodedPart), {
|
|
1108
|
+
onFailure: () => ModelProtocolError.make({ message: "Model response part failed canonical decoding" }),
|
|
1109
|
+
onSuccess: (ownedPart) => ({
|
|
1110
|
+
ownedPart,
|
|
1111
|
+
retainedBytes: captured.retainedBytes
|
|
1112
|
+
})
|
|
1113
|
+
}));
|
|
1101
1114
|
});
|
|
1102
1115
|
const hasTool = (tools, name) => Object.hasOwn(tools, name);
|
|
1103
1116
|
const startPart = (parts, id, description) => {
|
|
@@ -1555,6 +1568,7 @@ const toolFailureMessage = (message) => {
|
|
|
1555
1568
|
};
|
|
1556
1569
|
const executePreparedToolCall = Effect.fnUntraced(function* (context, turnId, toolkit, prepared, trace, resultBounds, onWaiting) {
|
|
1557
1570
|
const call = prepared.call;
|
|
1571
|
+
const toolCallId = prepared.toolCallId;
|
|
1558
1572
|
const observer = context.toolFailureObserver;
|
|
1559
1573
|
const telemetryToolCallId = isTelemetryToolCallId(call.id) ? call.id : void 0;
|
|
1560
1574
|
const executionClass = getToolExecutionClass(prepared.tool);
|
|
@@ -1575,7 +1589,6 @@ const executePreparedToolCall = Effect.fnUntraced(function* (context, turnId, to
|
|
|
1575
1589
|
let propagatedFailure;
|
|
1576
1590
|
const terminalTelemetry = (outcome, handling) => isolateToolDerivative(terminalToolTelemetry(telemetryDescriptor, outcome, outcome === "failure" ? failureMarker() : void 0, handling));
|
|
1577
1591
|
const started = Result.isFailure(prepared.validation) ? Effect.void : Effect.gen(function* () {
|
|
1578
|
-
const toolCallId = yield* decodeToolCallId(call.id);
|
|
1579
1592
|
yield* Effect.logDebug("agent tool handler started").pipe(Effect.annotateLogs({
|
|
1580
1593
|
agentId: context.agentId,
|
|
1581
1594
|
runId: context.runId,
|
|
@@ -1601,7 +1614,6 @@ const executePreparedToolCall = Effect.fnUntraced(function* (context, turnId, to
|
|
|
1601
1614
|
}))));
|
|
1602
1615
|
const results = prepareWithinDeadline(context, Stream.runForEach(handlerResults, (result) => Effect.gen(function* () {
|
|
1603
1616
|
if (terminal || trace.finalToolResultIds.has(call.id)) return yield* ModelProtocolError.make({ message: `Tool Call ${call.id} produced more than one terminal result` });
|
|
1604
|
-
const toolCallId = yield* decodeToolCallId(call.id);
|
|
1605
1617
|
const encodedResult = toolResultForJson(prepared.tool, result);
|
|
1606
1618
|
if (result.preliminary) {
|
|
1607
1619
|
const owned = yield* ownApplicationToolProgress(context, encodedResult);
|
|
@@ -1626,13 +1638,12 @@ const executePreparedToolCall = Effect.fnUntraced(function* (context, turnId, to
|
|
|
1626
1638
|
yield* checkpointExecution(context);
|
|
1627
1639
|
if (!terminal || terminalResult === void 0) return yield* ModelProtocolError.make({ message: `Tool Call ${call.id} completed without a terminal result` });
|
|
1628
1640
|
const result = terminalResult;
|
|
1629
|
-
const toolCallId = yield* decodeToolCallId(call.id);
|
|
1630
1641
|
let toolSelection;
|
|
1631
1642
|
if (!result.isFailure && Context.get(prepared.tool.annotations, DiscoveryTool)) {
|
|
1632
1643
|
toolSelection = yield* validateSelection(result.result, context.definition, context.toolCatalog);
|
|
1633
1644
|
yield* exposureSnapshot(context.definition, toolSelection, context.toolCatalog, context.toolSchemaTransformer);
|
|
1634
1645
|
}
|
|
1635
|
-
const encodedResult = boundEncodedToolResult(result.encodedResult, resultBounds);
|
|
1646
|
+
const encodedResult = yield* boundEncodedToolResult(result.encodedResult, resultBounds);
|
|
1636
1647
|
const successResult = result.isFailure ? void 0 : yield* decodeEventJson(encodedResult, "Tool result");
|
|
1637
1648
|
trace.finalToolResultIds.add(call.id);
|
|
1638
1649
|
trace.applicationToolResults[prepared.declarationIndex] = {
|
|
@@ -1841,43 +1852,40 @@ const executeToolBatch = Effect.fnUntraced(function* (context, turnId, turn, too
|
|
|
1841
1852
|
})) };
|
|
1842
1853
|
const permits = yield* Semaphore.make(concurrency);
|
|
1843
1854
|
const handlers = Effect.gen(function* () {
|
|
1844
|
-
for (const group of groups) {
|
|
1845
|
-
yield* Effect.forEach(group, (call) => permits.withPermit(Effect.acquireUseRelease(Effect.forkScoped(Effect.scoped(Effect.gen(function* () {
|
|
1846
|
-
yield* checkpointExecution(context, durability);
|
|
1847
|
-
const subagentHost = yield* SubagentHost.forTool;
|
|
1848
|
-
const messagingHost = yield* MessagingHost.forTool;
|
|
1849
|
-
const source = {
|
|
1850
|
-
_tag: "tool",
|
|
1851
|
-
agentId: context.agentId,
|
|
1852
|
-
threadId: context.threadId,
|
|
1853
|
-
runId: context.runId,
|
|
1854
|
-
toolCallId: call.toolCallId
|
|
1855
|
-
};
|
|
1856
|
-
const broker = yield* makeToolBrokerService({
|
|
1857
|
-
context,
|
|
1858
|
-
turnId,
|
|
1859
|
-
outerToolCallId: call.toolCallId,
|
|
1860
|
-
turn,
|
|
1861
|
-
maxToolCalls: brokerAccounting.maxToolCalls,
|
|
1862
|
-
declaredToolCalls: brokerAccounting.declaredToolCalls,
|
|
1863
|
-
budget: options.budget,
|
|
1864
|
-
reservePolicyUsage: durability?.reservePolicyUsage,
|
|
1865
|
-
hookServices
|
|
1866
|
-
});
|
|
1867
|
-
const step = stepServiceFor(call);
|
|
1868
|
-
const subagent = subagentHost(source);
|
|
1869
|
-
const messaging = messagingHost(source);
|
|
1870
|
-
const catalog = { entries: context.toolCatalog };
|
|
1871
|
-
return yield* executePreparedToolCall(context, turnId, toolkit, call, trace, resultBounds, (waiting) => {
|
|
1872
|
-
waitingByDeclaration.set(call.declarationIndex, waiting);
|
|
1873
|
-
}).pipe(Effect.updateContext((services) => services.pipe(Context.add(CurrentToolCatalog, catalog), Context.add(ToolBroker, broker.service), Context.add(MessagingHost, messaging), Context.add(SubagentHost, subagent), Context.add(DurableStep, step))), Effect.ensuring(Effect.sync(() => broker.close())));
|
|
1874
|
-
}))), Fiber.join, Fiber.interrupt)), {
|
|
1875
|
-
concurrency: group.length === 1 ? 1 : "unbounded",
|
|
1876
|
-
discard: true
|
|
1877
|
-
});
|
|
1855
|
+
for (const group of groups) yield* Effect.forEach(group, (call) => permits.withPermit(Effect.acquireUseRelease(Effect.forkScoped(Effect.scoped(Effect.gen(function* () {
|
|
1878
1856
|
yield* checkpointExecution(context, durability);
|
|
1879
|
-
|
|
1880
|
-
|
|
1857
|
+
const subagentHost = yield* SubagentHost.forTool;
|
|
1858
|
+
const messagingHost = yield* MessagingHost.forTool;
|
|
1859
|
+
const source = {
|
|
1860
|
+
_tag: "tool",
|
|
1861
|
+
agentId: context.agentId,
|
|
1862
|
+
threadId: context.threadId,
|
|
1863
|
+
runId: context.runId,
|
|
1864
|
+
toolCallId: call.toolCallId
|
|
1865
|
+
};
|
|
1866
|
+
const broker = yield* makeToolBrokerService({
|
|
1867
|
+
context,
|
|
1868
|
+
turnId,
|
|
1869
|
+
outerToolCallId: call.toolCallId,
|
|
1870
|
+
turn,
|
|
1871
|
+
maxToolCalls: brokerAccounting.maxToolCalls,
|
|
1872
|
+
declaredToolCalls: brokerAccounting.declaredToolCalls,
|
|
1873
|
+
budget: options.budget,
|
|
1874
|
+
reservePolicyUsage: durability?.reservePolicyUsage,
|
|
1875
|
+
hookServices
|
|
1876
|
+
});
|
|
1877
|
+
const step = stepServiceFor(call);
|
|
1878
|
+
const subagent = subagentHost(source);
|
|
1879
|
+
const messaging = messagingHost(source);
|
|
1880
|
+
const catalog = { entries: context.toolCatalog };
|
|
1881
|
+
return yield* executePreparedToolCall(context, turnId, toolkit, call, trace, resultBounds, (waiting) => {
|
|
1882
|
+
waitingByDeclaration.set(call.declarationIndex, waiting);
|
|
1883
|
+
}).pipe(Effect.updateContext((services) => services.pipe(Context.add(CurrentToolCatalog, catalog), Context.add(ToolBroker, broker.service), Context.add(MessagingHost, messaging), Context.add(SubagentHost, subagent), Context.add(DurableStep, step))), Effect.ensuring(Effect.sync(() => broker.close())));
|
|
1884
|
+
}))), Fiber.join, Fiber.interrupt)), {
|
|
1885
|
+
concurrency: group.length === 1 ? 1 : "unbounded",
|
|
1886
|
+
discard: true
|
|
1887
|
+
});
|
|
1888
|
+
}).pipe(Effect.updateContext((services) => services.pipe(Context.add(SubagentDurability, batchSubagentDurability), Context.add(Emitter, updateEmitter), Context.add(RunEventSink, batchSink))), Effect.ensuring(Effect.sync(() => {
|
|
1881
1889
|
updatesOpen = false;
|
|
1882
1890
|
})));
|
|
1883
1891
|
yield* guardBudgetEffect(handlers, options.budget);
|
|
@@ -2001,26 +2009,22 @@ const toolResultForJson = (tool, result) => {
|
|
|
2001
2009
|
if (!result.isFailure && result.encodedResult === void 0 && SchemaAST.isVoid(SchemaAST.toEncoded(tool.successSchema.ast))) return Schema.encodeSync(Schema.toCodecJson(Schema.Void))(void 0);
|
|
2002
2010
|
return result.encodedResult;
|
|
2003
2011
|
};
|
|
2012
|
+
const decodeBoundedToolResult = Schema.decodeEffect(Schema.fromJsonString(Schema.Unknown));
|
|
2004
2013
|
/**
|
|
2005
2014
|
* RUN-022: bound one application Tool result at the settle seam. The bounded
|
|
2006
2015
|
* value is what official history, the settled record, and the success event
|
|
2007
|
-
* all carry, so every downstream surface agrees
|
|
2008
|
-
* passes through with its identity preserved.
|
|
2016
|
+
* all carry, so every downstream surface agrees on the measured representation.
|
|
2009
2017
|
*/
|
|
2010
2018
|
const boundEncodedToolResult = (encodedResult, bounds) => {
|
|
2011
2019
|
let text;
|
|
2012
2020
|
try {
|
|
2013
2021
|
text = JSON.stringify(encodedResult);
|
|
2014
2022
|
} catch (cause) {
|
|
2015
|
-
return unserializableToolResult(cause);
|
|
2023
|
+
return Effect.succeed(unserializableToolResult(cause));
|
|
2016
2024
|
}
|
|
2017
|
-
if (text === void 0) return unserializableToolResult("the encoded result is not a JSON value");
|
|
2025
|
+
if (text === void 0) return Effect.succeed(unserializableToolResult("the encoded result is not a JSON value"));
|
|
2018
2026
|
const bounded = applyToolResultBounds(text, bounds);
|
|
2019
|
-
|
|
2020
|
-
return Schema.decodeSync(Schema.fromJsonString(Schema.Unknown))(bounded);
|
|
2021
|
-
} catch (cause) {
|
|
2022
|
-
return unserializableToolResult(cause);
|
|
2023
|
-
}
|
|
2027
|
+
return decodeBoundedToolResult(bounded).pipe(Effect.orElseSucceed(unserializableToolResult));
|
|
2024
2028
|
};
|
|
2025
2029
|
const durableResultBounds = (bounds, options, turn) => ToolResultBounds.make({ maxBytes: Math.min(bounds.maxBytes, options.durability?.toolResultMaxBytes ?? bounds.maxBytes, options.resume?.turn === turn ? options.resume.toolResultMaxBytes ?? bounds.maxBytes : bounds.maxBytes) });
|
|
2026
2030
|
const RUN_STATUS_WARNING = " · WARNING: approaching limits — converge and deliver your final result now.";
|
|
@@ -2091,13 +2095,13 @@ const consumeUsage = (agent, context, usage, toolCallCount, turn, options, respo
|
|
|
2091
2095
|
const reportedText = providerUsage.outputTokens.text ?? 0;
|
|
2092
2096
|
const reasoning = providerUsage.outputTokens.reasoning ?? 0;
|
|
2093
2097
|
const reportedInputTotal = providerUsage.inputTokens.total;
|
|
2094
|
-
const reportedInputWithoutWrite =
|
|
2098
|
+
const reportedInputWithoutWrite = reportedUncached + cacheRead;
|
|
2095
2099
|
const disjointReportedUncached = reportedUncached - (reportedInputTotal !== void 0 && providerUsage.inputTokens.uncached !== void 0 && providerUsage.inputTokens.cacheWrite !== void 0 && cacheWrite <= reportedUncached && reportedInputWithoutWrite <= reportedInputTotal && cacheWrite > reportedInputTotal - reportedInputWithoutWrite ? cacheWrite : 0);
|
|
2096
|
-
const reportedInputComponents =
|
|
2100
|
+
const reportedInputComponents = disjointReportedUncached + cacheRead + cacheWrite;
|
|
2097
2101
|
const allInputComponentsReported = providerUsage.inputTokens.uncached !== void 0 && providerUsage.inputTokens.cacheRead !== void 0 && providerUsage.inputTokens.cacheWrite !== void 0;
|
|
2098
2102
|
if (reportedInputTotal !== void 0 && (reportedInputTotal < reportedInputComponents || allInputComponentsReported && reportedInputTotal !== reportedInputComponents)) return yield* invalidProviderUsage();
|
|
2099
2103
|
const inputTokens = reportedInputTotal ?? reportedInputComponents;
|
|
2100
|
-
const reportedOutputComponents =
|
|
2104
|
+
const reportedOutputComponents = reportedText + reasoning;
|
|
2101
2105
|
const reportedOutputTotal = providerUsage.outputTokens.total;
|
|
2102
2106
|
const allOutputComponentsReported = providerUsage.outputTokens.text !== void 0 && providerUsage.outputTokens.reasoning !== void 0;
|
|
2103
2107
|
if (reportedOutputTotal !== void 0 && (reportedOutputTotal < reportedOutputComponents || allOutputComponentsReported && reportedOutputTotal !== reportedOutputComponents)) return yield* invalidProviderUsage();
|
|
@@ -2109,6 +2113,17 @@ const consumeUsage = (agent, context, usage, toolCallCount, turn, options, respo
|
|
|
2109
2113
|
const normalizedCacheWrite = cacheWrite + (providerUsage.inputTokens.uncached !== void 0 && providerUsage.inputTokens.cacheRead !== void 0 && providerUsage.inputTokens.cacheWrite === void 0 ? inputRemainder : 0);
|
|
2110
2114
|
const text = reportedText + (providerUsage.outputTokens.text === void 0 ? outputRemainder : 0);
|
|
2111
2115
|
const normalizedReasoning = reasoning + (providerUsage.outputTokens.text !== void 0 && providerUsage.outputTokens.reasoning === void 0 ? outputRemainder : 0);
|
|
2116
|
+
const inputUsage = yield* InputTokenUsage.makeEffect({
|
|
2117
|
+
total: inputTokens,
|
|
2118
|
+
uncached,
|
|
2119
|
+
cacheRead: normalizedCacheRead,
|
|
2120
|
+
cacheWrite: normalizedCacheWrite
|
|
2121
|
+
}).pipe(Effect.mapError(() => invalidProviderUsage()));
|
|
2122
|
+
const outputUsage = yield* OutputTokenUsage.makeEffect({
|
|
2123
|
+
total: outputTokens,
|
|
2124
|
+
text,
|
|
2125
|
+
reasoning: normalizedReasoning
|
|
2126
|
+
}).pipe(Effect.mapError(() => invalidProviderUsage()));
|
|
2112
2127
|
const totalTokens = yield* decodeProviderUsageTotal(inputTokens + outputTokens);
|
|
2113
2128
|
const provider = yield* Model.ProviderName;
|
|
2114
2129
|
const model = yield* Model.ModelName;
|
|
@@ -2148,17 +2163,8 @@ const consumeUsage = (agent, context, usage, toolCallCount, turn, options, respo
|
|
|
2148
2163
|
pricingStatus,
|
|
2149
2164
|
...serviceTier === void 0 ? {} : { serviceTier },
|
|
2150
2165
|
...pricingVersion === void 0 ? {} : { pricingVersion },
|
|
2151
|
-
inputTokens:
|
|
2152
|
-
|
|
2153
|
-
uncached,
|
|
2154
|
-
cacheRead: normalizedCacheRead,
|
|
2155
|
-
cacheWrite: normalizedCacheWrite
|
|
2156
|
-
}),
|
|
2157
|
-
outputTokens: OutputTokenUsage.make({
|
|
2158
|
-
total: outputTokens,
|
|
2159
|
-
text,
|
|
2160
|
-
reasoning: normalizedReasoning
|
|
2161
|
-
}),
|
|
2166
|
+
inputTokens: inputUsage,
|
|
2167
|
+
outputTokens: outputUsage,
|
|
2162
2168
|
costMicrousd
|
|
2163
2169
|
});
|
|
2164
2170
|
const modelCalls = yield* decodeProviderUsageTotal(context.modelCalls + 1);
|
|
@@ -2639,9 +2645,9 @@ const decodeProviderToolCallIdValue = Schema.decodeEffect(ProviderToolCallId);
|
|
|
2639
2645
|
const decodeProviderResponsePartIdValue = Schema.decodeEffect(ProviderResponsePartId);
|
|
2640
2646
|
const decodeJson = Schema.decodeUnknownEffect(Schema.Json);
|
|
2641
2647
|
const decodeToolCallId = (id) => Effect.suspend(() => decodeToolCallIdValue(id).pipe(Effect.mapError((cause) => ModelProtocolError.make({ message: `Invalid Tool Call ID: ${cause.message}` }))));
|
|
2642
|
-
const decodeProviderToolCallId = (id) =>
|
|
2643
|
-
const decodeProviderResponsePartId = (id) =>
|
|
2644
|
-
const validateProviderPartIdentifiers = Effect.
|
|
2648
|
+
const decodeProviderToolCallId = (id) => decodeProviderToolCallIdValue(id).pipe(Effect.mapErrorEager(() => ModelProtocolError.make({ message: "Model supplied an invalid Tool Call ID; expected 1-128 ASCII letters, digits, dots, underscores, colons, or hyphens" })));
|
|
2649
|
+
const decodeProviderResponsePartId = (id) => decodeProviderResponsePartIdValue(id).pipe(Effect.mapErrorEager(() => ModelProtocolError.make({ message: "Model supplied an invalid response part ID; expected 1-128 ASCII letters, digits, dots, underscores, colons, or hyphens" })));
|
|
2650
|
+
const validateProviderPartIdentifiers = Effect.fnUntracedEager(function* (part) {
|
|
2645
2651
|
switch (part.type) {
|
|
2646
2652
|
case "text-start":
|
|
2647
2653
|
case "text-delta":
|
|
@@ -2711,7 +2717,7 @@ const promptFromTurnParts = (trace) => {
|
|
|
2711
2717
|
if (!attachedProviderResults) messages.push(Prompt.makeMessage("assistant", { content: providerResults }));
|
|
2712
2718
|
return Prompt.fromMessages(messages);
|
|
2713
2719
|
};
|
|
2714
|
-
const processModelPart = Effect.
|
|
2720
|
+
const processModelPart = Effect.fnUntracedEager(function* (context, turnId, turn, tools, trace, part, retainedBytes, events) {
|
|
2715
2721
|
trace.responsePartCount++;
|
|
2716
2722
|
trace.responsePartBytes += retainedBytes;
|
|
2717
2723
|
if (part.type === "finish" && trace.usage === void 0) {
|
|
@@ -3335,7 +3341,7 @@ const makeTurn = (agent, context, prompt, turn, priorToolCalls, options, restart
|
|
|
3335
3341
|
const exit = yield* consumeTurnUsage(0).pipe(Effect.exit);
|
|
3336
3342
|
if (Exit.isFailure(exit)) failedUsageCause = exit.cause;
|
|
3337
3343
|
});
|
|
3338
|
-
const attempt = (basis) => Effect.flatten(outgoingModelPrompt(policy, context, prepareModelPrompt(Prompt.
|
|
3344
|
+
const attempt = (basis) => Effect.flatten(outgoingModelPrompt(policy, context, prepareModelPrompt(Prompt.concat(basis, transientContext), outputContract._tag === "rendered" ? outputContract.part : void 0, systemMessagesInHistory, staticInstructions), turn, priorToolCalls, systemMessagesInHistory).pipe(withCallModel, Effect.flatMap((providerPrompt) => Effect.gen(function* () {
|
|
3339
3345
|
yield* checkpointExecution(context, options.durability);
|
|
3340
3346
|
const toolChoice = modelToolChoice();
|
|
3341
3347
|
let requestToolkit = modelToolkit;
|
|
@@ -3372,22 +3378,24 @@ const makeTurn = (agent, context, prompt, turn, priorToolCalls, options, restart
|
|
|
3372
3378
|
trace.usageConsumed = false;
|
|
3373
3379
|
provisionalText = !restartRequested && attempt?.threadId === context.threadId ? attempt.openModel(context.runId, turnId) : void 0;
|
|
3374
3380
|
activeProvisionalText = provisionalText;
|
|
3375
|
-
})), Stream.
|
|
3376
|
-
const
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3381
|
+
})), Stream.runForEachArray((parts) => Effect.gen(function* () {
|
|
3382
|
+
for (const part of parts) {
|
|
3383
|
+
const owned = yield* ownModelResponsePart(part, agent.definition.toolkit, trace, context.bufferLimits, trace.finished);
|
|
3384
|
+
const events = context.publish === void 0 ? void 0 : [];
|
|
3385
|
+
yield* processModelPart(context, turnId, turn, agent.definition.toolkit.tools, trace, owned.ownedPart, owned.retainedBytes, events);
|
|
3386
|
+
if (provisionalText !== void 0) {
|
|
3387
|
+
const part = owned.ownedPart;
|
|
3388
|
+
if (part.type === "text-start" || part.type === "text-delta" || part.type === "text-end") provisionalText.offerUnsafe(part);
|
|
3389
|
+
}
|
|
3390
|
+
if (events !== void 0) yield* publishEvents(context, events);
|
|
3382
3391
|
}
|
|
3383
|
-
if (events !== void 0) yield* publishEvents(context, events);
|
|
3384
3392
|
})), (effect) => prepareWithinDeadline(context, effect), Effect.onExit((exit) => {
|
|
3385
3393
|
if (Exit.isSuccess(exit)) return Effect.void;
|
|
3386
3394
|
provisionalText?.discard();
|
|
3387
3395
|
return retainFailedUsage();
|
|
3388
3396
|
}))));
|
|
3389
3397
|
}))));
|
|
3390
|
-
const attemptWithRetries = Effect.suspend(() => attempt(compactedOutgoing())).pipe(Effect.retry(($) => $(Schedule.exponential(MODEL_RETRY_BASE)).pipe(Schedule.upTo({ times: policy.modelRetries ?? 0 }), Schedule.while(({ input: error }) => {
|
|
3398
|
+
const attemptWithRetries = Effect.suspend(() => attempt(compactedOutgoing())).pipe((operation) => (policy.modelRetries ?? 0) === 0 ? operation : Effect.retry(operation, ($) => $(Schedule.exponential(MODEL_RETRY_BASE)).pipe(Schedule.upTo({ times: policy.modelRetries ?? 0 }), Schedule.while(({ input: error }) => {
|
|
3391
3399
|
const lastPart = trace.parts.at(-1);
|
|
3392
3400
|
const providerError = error;
|
|
3393
3401
|
return canRepeatModelCall && !hasStreamedContent(trace) && (lastPart?.type === "error" && isTransientErrorPayload(lastPart.error) || AiError.isAiError(providerError) && providerError.isRetryable);
|
|
@@ -3852,7 +3860,7 @@ const makeResumeTurn = (agent, context, prompt, resume, countedToolCalls, option
|
|
|
3852
3860
|
settledCalls.push({
|
|
3853
3861
|
id: call.id,
|
|
3854
3862
|
isFailure: true,
|
|
3855
|
-
result: yield* decodeEventJson(boundEncodedToolResult(rejection.error, durableResultBounds(agent.definition.policy.toolResultBounds, options, turn)), "Rejected Tool result")
|
|
3863
|
+
result: yield* decodeEventJson(yield* boundEncodedToolResult(rejection.error, durableResultBounds(agent.definition.policy.toolResultBounds, options, turn)), "Rejected Tool result")
|
|
3856
3864
|
});
|
|
3857
3865
|
recordedSettledIds.add(call.id);
|
|
3858
3866
|
}
|
|
@@ -4069,11 +4077,10 @@ function executeWithCompletion(agentValue, input, runOptions = {}, onCompleted,
|
|
|
4069
4077
|
const attemptDeadlineMillis = attemptStartedAtMillis + Duration.toMillis(agent.definition.policy.maxDuration);
|
|
4070
4078
|
const durationDeadlineMillis = options.durationDeadline === void 0 ? attemptDeadlineMillis : Math.min(attemptDeadlineMillis, DateTime.toEpochMillis(options.durationDeadline));
|
|
4071
4079
|
const startedAtMillis = options.runStartedAt === void 0 ? attemptStartedAtMillis : DateTime.toEpochMillis(options.runStartedAt);
|
|
4072
|
-
const programmaticAuthorization =
|
|
4073
|
-
const services = yield* Effect.context();
|
|
4080
|
+
const programmaticAuthorization = Effect.map(Effect.context(), (services) => {
|
|
4074
4081
|
const selected = options.toolAuthorization;
|
|
4075
4082
|
return ProgrammaticToolAuthorization.of({ authorize: (request) => selected === void 0 ? Effect.succeed({ _tag: "allowed" }) : provideHookServices(selected.authorize(request), services).pipe(Effect.catchCauseFilter(Cause.findError, (error, cause) => Effect.fail(new BrokerCallFailure(error, cause)))) });
|
|
4076
|
-
})
|
|
4083
|
+
});
|
|
4077
4084
|
const interpreted = Effect.flatten(Effect.gen(function* () {
|
|
4078
4085
|
const resumed = options.resume === void 0 ? void 0 : {
|
|
4079
4086
|
batch: options.resume,
|
|
@@ -4264,8 +4271,10 @@ function executeWithCompletion(agentValue, input, runOptions = {}, onCompleted,
|
|
|
4264
4271
|
let request = pending;
|
|
4265
4272
|
while (request !== void 0) {
|
|
4266
4273
|
const output = yield* Effect.scoped(request.resume === void 0 ? makeTurn(agent, context, request.prompt, request.turn, request.toolCalls, options, request.restarting) : makeResumeTurn(agent, context, request.prompt, request.resume, request.toolCalls, options));
|
|
4267
|
-
|
|
4268
|
-
|
|
4274
|
+
if (output._tag !== "NextTurn") {
|
|
4275
|
+
yield* checkpointExecution(context, options.durability);
|
|
4276
|
+
return output;
|
|
4277
|
+
}
|
|
4269
4278
|
request = output;
|
|
4270
4279
|
}
|
|
4271
4280
|
return yield* ModelProtocolError.make({ message: "Agent execution ended without RunCompleted" });
|
|
@@ -4358,7 +4367,7 @@ function executeWithCompletion(agentValue, input, runOptions = {}, onCompleted,
|
|
|
4358
4367
|
const events = (model === void 0 ? finalized : Effect.gen(function* () {
|
|
4359
4368
|
const services = yield* beforeExecutionDeadline(Layer.build(Layer.fresh(model)), durationDeadlineMillis, durationFailure);
|
|
4360
4369
|
return yield* Effect.provide(finalized, services);
|
|
4361
|
-
})).pipe(Effect.
|
|
4370
|
+
})).pipe(Effect.provideServiceEffect(ToolSpanTelemetry, ToolSpanTelemetry.make), Effect.provideServiceEffect(ProgrammaticToolAuthorization, programmaticAuthorization));
|
|
4362
4371
|
return Effect.scoped(events).pipe(Effect.flatMap((terminal) => Effect.gen(function* () {
|
|
4363
4372
|
if (onCompleted !== void 0) yield* onCompleted(terminal);
|
|
4364
4373
|
if (retained !== void 0) yield* retained.commit(terminal);
|
|
@@ -5207,4 +5216,4 @@ var AgentRuntime_exports = /* @__PURE__ */ __exportAll({
|
|
|
5207
5216
|
//#endregion
|
|
5208
5217
|
export { boundedValueFootprint as C, withAttempt as S, startUnknown as _, SubagentDurability as a, streamWithUsageAccountingUnknown as b, decodeFinalOutput as c, projectCompletionFromToolOutput as d, projectCompletionOutput as f, start as g, runUnknown as h, AgentSpawner as i, encodeRunDisposition as l, run as m, AgentChildPending as n, SubagentDurabilityError as o, renderInputPrompt as p, AgentResultSchema as r, ToolCallWaiting as s, AgentRuntime_exports as t, executeWithUsageAccountingUnknown as u, stream as v, withTerminalDefectEvent as x, streamUnknown as y };
|
|
5209
5218
|
|
|
5210
|
-
//# sourceMappingURL=AgentRuntime-
|
|
5219
|
+
//# sourceMappingURL=AgentRuntime-DaDKMasp.mjs.map
|