effect-agent 0.1.0-beta.86 → 0.1.0-beta.88
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/{AgentRuntime-BLyETCPo.mjs → AgentRuntime-CHipL2jG.mjs} +42 -6
- package/dist/AgentRuntime-CHipL2jG.mjs.map +1 -0
- package/dist/{DurableAgentRuntime-sOrBVu4B.mjs → DurableAgentRuntime-D7gDKGjH.mjs} +4 -2
- package/dist/{DurableAgentRuntime-sOrBVu4B.mjs.map → DurableAgentRuntime-D7gDKGjH.mjs.map} +1 -1
- package/dist/{Subagent-Cy_hU1tv.mjs → Subagent-U5qXOFE8.mjs} +2 -2
- package/dist/{Subagent-Cy_hU1tv.mjs.map → Subagent-U5qXOFE8.mjs.map} +1 -1
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
- package/src/durable/DurableAgentRuntime.ts +12 -0
- package/src/engine/internal/agent-runtime.ts +49 -4
- package/dist/AgentRuntime-BLyETCPo.mjs.map +0 -1
|
@@ -1298,8 +1298,43 @@ const preflightToolAuthorization = (context, turnId, turn, call, options, annota
|
|
|
1298
1298
|
const ProviderResponsePartId = Schema.String.check(Schema.isMaxLength(128), Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/));
|
|
1299
1299
|
const ProviderToolCallId = ToolCallId.check(Schema.isMaxLength(128), Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/));
|
|
1300
1300
|
const isTelemetryToolCallId = Schema.is(ProviderToolCallId);
|
|
1301
|
+
/** A definition names the agent; its Thread identifies the continuing instance and conversation. */
|
|
1302
|
+
const agentTelemetryAttributes = (context) => ({
|
|
1303
|
+
"gen_ai.agent.name": context.agentId,
|
|
1304
|
+
"gen_ai.agent.id": context.threadId,
|
|
1305
|
+
"gen_ai.conversation.id": context.threadId
|
|
1306
|
+
});
|
|
1307
|
+
/** Label Effect AI's existing span, preserving provider usage, sampling and host async context. */
|
|
1308
|
+
const modelTelemetryTracer = Effect.fnUntraced(function* (context, turnId) {
|
|
1309
|
+
const delegate = yield* Tracer.Tracer;
|
|
1310
|
+
const model = yield* Model.ModelName;
|
|
1311
|
+
const provider = yield* Model.ProviderName;
|
|
1312
|
+
return Tracer.make({
|
|
1313
|
+
span(options) {
|
|
1314
|
+
if (options.name !== "LanguageModel.streamText") return delegate.span(options);
|
|
1315
|
+
const span = delegate.span({
|
|
1316
|
+
...options,
|
|
1317
|
+
name: `chat ${model}`
|
|
1318
|
+
});
|
|
1319
|
+
const attributes = {
|
|
1320
|
+
...agentTelemetryAttributes(context),
|
|
1321
|
+
"gen_ai.operation.name": "chat",
|
|
1322
|
+
"gen_ai.request.model": model,
|
|
1323
|
+
"gen_ai.provider.name": provider,
|
|
1324
|
+
agentId: context.agentId,
|
|
1325
|
+
threadId: context.threadId,
|
|
1326
|
+
runId: context.runId,
|
|
1327
|
+
...turnId === void 0 ? {} : { turnId }
|
|
1328
|
+
};
|
|
1329
|
+
for (const [key, value] of Object.entries(attributes)) span.attribute(key, value);
|
|
1330
|
+
return span;
|
|
1331
|
+
},
|
|
1332
|
+
...delegate.context === void 0 ? {} : { context: delegate.context.bind(delegate) }
|
|
1333
|
+
});
|
|
1334
|
+
});
|
|
1301
1335
|
/** One bounded identity surface shared by canonical Tool spans and terminal logs. */
|
|
1302
1336
|
const toolTelemetryAttributes = (descriptor) => ({
|
|
1337
|
+
...agentTelemetryAttributes(descriptor.context),
|
|
1303
1338
|
"gen_ai.operation.name": "execute_tool",
|
|
1304
1339
|
"gen_ai.tool.name": descriptor.toolName,
|
|
1305
1340
|
"gen_ai.tool.type": "function",
|
|
@@ -1307,8 +1342,6 @@ const toolTelemetryAttributes = (descriptor) => ({
|
|
|
1307
1342
|
"gen_ai.tool.call.id": descriptor.toolCallId,
|
|
1308
1343
|
toolCallId: descriptor.toolCallId
|
|
1309
1344
|
},
|
|
1310
|
-
"gen_ai.agent.name": descriptor.context.agentId,
|
|
1311
|
-
"gen_ai.conversation.id": descriptor.context.threadId,
|
|
1312
1345
|
"effect_agent.tool.execution_class": descriptor.executionClass,
|
|
1313
1346
|
"effect_agent.tool.invocation_kind": descriptor.invocationKind,
|
|
1314
1347
|
"effect_agent.tool.failure_mode": descriptor.failureMode,
|
|
@@ -2180,7 +2213,7 @@ const compactContext = (agent, context, source, turn, options, resolvedModelInpu
|
|
|
2180
2213
|
let summaryFailure;
|
|
2181
2214
|
const textParts = /* @__PURE__ */ new Map();
|
|
2182
2215
|
const reasoningParts = /* @__PURE__ */ new Map();
|
|
2183
|
-
const summaryExit = yield* guardBudgetStream(LanguageModel.streamText({ prompt: summarizerPrompt }), options.budget).pipe(Stream.runForEach((part) => Effect.gen(function* () {
|
|
2216
|
+
const summaryExit = yield* guardBudgetStream(LanguageModel.streamText({ prompt: summarizerPrompt }), options.budget).pipe(Stream.provideServiceEffect(Tracer.Tracer, modelTelemetryTracer(context)), Stream.runForEach((part) => Effect.gen(function* () {
|
|
2184
2217
|
const owned = yield* ownModelResponsePart(part, Toolkit.empty, responseUsage, context.bufferLimits);
|
|
2185
2218
|
yield* consumeModelResponsePart(responseUsage, owned.retainedBytes, context.bufferLimits);
|
|
2186
2219
|
const ownedPart = owned.ownedPart;
|
|
@@ -3003,7 +3036,7 @@ const makeTurn = (agent, context, prompt, turn, priorToolCalls, options) => Stre
|
|
|
3003
3036
|
toolkit: requestToolkit,
|
|
3004
3037
|
disableToolCallResolution: true,
|
|
3005
3038
|
...toolChoice === void 0 ? {} : { toolChoice }
|
|
3006
|
-
}), options.budget).pipe(Stream.onStart(Effect.sync(() => {
|
|
3039
|
+
}), options.budget).pipe(Stream.provideServiceEffect(Tracer.Tracer, modelTelemetryTracer(context, turnId)), Stream.onStart(Effect.sync(() => {
|
|
3007
3040
|
trace.usageConsumed = false;
|
|
3008
3041
|
})), Stream.mapEffect((part) => ownModelResponsePart(part, agent.definition.toolkit, trace, context.bufferLimits).pipe(Effect.flatMap((owned) => eventsForPart(context, turnId, turn, agent.definition.toolkit.tools, trace, owned.ownedPart, owned.retainedBytes)))), Stream.flatMap(Stream.fromIterable), Stream.tapCause(() => retainFailedUsage()))));
|
|
3009
3042
|
}))));
|
|
@@ -3724,8 +3757,11 @@ function streamWithCompletion(agentValue, input, runOptions = {}, onCompleted, o
|
|
|
3724
3757
|
message: errorMessage(error)
|
|
3725
3758
|
});
|
|
3726
3759
|
})).pipe(Stream.concat(Stream.fail(error)));
|
|
3727
|
-
}), Stream.withSpan(
|
|
3760
|
+
}), Stream.withSpan(`invoke_agent ${context.agentId}`, { attributes: {
|
|
3761
|
+
...agentTelemetryAttributes(context),
|
|
3762
|
+
"gen_ai.operation.name": "invoke_agent",
|
|
3728
3763
|
agentId: context.agentId,
|
|
3764
|
+
threadId: context.threadId,
|
|
3729
3765
|
runId: context.runId
|
|
3730
3766
|
} }), Stream.provide(engineToolServices), Stream.provideService(ContextCompactor, compactor));
|
|
3731
3767
|
}));
|
|
@@ -4559,4 +4595,4 @@ var AgentRuntime_exports = /* @__PURE__ */ __exportAll({
|
|
|
4559
4595
|
//#endregion
|
|
4560
4596
|
export { stream as _, SubagentDurability as a, withTerminalDefectEvent as b, decodeFinalOutput as c, projectCompletionOutput as d, renderInputPrompt as f, startUnknown as g, start as h, AgentSpawner as i, encodeRunDisposition as l, runUnknown as m, AgentChildPending as n, SubagentDurabilityError as o, run as p, AgentResultSchema as r, ToolCallWaiting as s, AgentRuntime_exports as t, projectCompletionFromToolOutput as u, streamUnknown as v, streamWithUsageAccountingUnknown as y };
|
|
4561
4597
|
|
|
4562
|
-
//# sourceMappingURL=AgentRuntime-
|
|
4598
|
+
//# sourceMappingURL=AgentRuntime-CHipL2jG.mjs.map
|