@sentry/junior 0.295.0 → 0.296.0

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.
Files changed (62) hide show
  1. package/dist/{admin-ifgjyfpF.js → admin-z_lgDi-z.js} +2 -2
  2. package/dist/{agent-runner-DjMTPWEO.js → agent-runner-HoQiUKLL.js} +194 -132
  3. package/dist/api/schema.d.ts +1 -1
  4. package/dist/api/schema.js +1 -1
  5. package/dist/api.d.ts +1 -1
  6. package/dist/api.js +294 -328
  7. package/dist/{app-uiTzRbvq.d.ts → app-C75Ft-A_.d.ts} +2 -2
  8. package/dist/app.d.ts +1 -1
  9. package/dist/app.js +26 -26
  10. package/dist/{background-compaction-queue-DUkHZjmL.js → background-compaction-queue-Cre1wFt9.js} +4 -4
  11. package/dist/{briefs-CbNYM-q2.js → briefs-BXECHduJ.js} +2 -2
  12. package/dist/{catalog-runtime-DgouZKZm.js → catalog-runtime-CpCmlD9L.js} +1 -1
  13. package/dist/cli/chat.js +14 -14
  14. package/dist/cli/check.js +3 -3
  15. package/dist/cli/main.js +3 -3
  16. package/dist/cli/plugins.js +4 -4
  17. package/dist/cli/snapshot-create.js +4 -4
  18. package/dist/cli/upgrade.d.ts +1 -1
  19. package/dist/cli/upgrade.js +3 -3
  20. package/dist/{config-DvnTPCfp.js → config-CCPHvTqx.js} +18 -2
  21. package/dist/{connections-CWaIVl_1.js → connections-B5pWh8e2.js} +6 -6
  22. package/dist/{conversation-privacy-DPjv4SnA.js → conversation-privacy-CZD5soDW.js} +1 -1
  23. package/dist/{credential-sync-BhbaZfmO.js → credential-sync-DwLkIvXI.js} +13 -13
  24. package/dist/{db-CCUqQe0E.d.ts → db-B3iyr_Or.d.ts} +1 -1
  25. package/dist/{db-Dts2XvLu.js → db-C1M1y-bh.js} +17 -23
  26. package/dist/{executor-Ck73J0wP.js → executor-DUSEwXaO.js} +10 -4
  27. package/dist/instrumentation.js +19 -2
  28. package/dist/{logging-9OAq-fdg.js → logging-D0svFM8r.js} +1 -1
  29. package/dist/{message-CtaPzC7m.js → message-BFnIwKpx.js} +9 -9
  30. package/dist/nitro.d.ts +1 -1
  31. package/dist/nitro.js +2 -2
  32. package/dist/{oauth-callback-server-C_LXY1d4.js → oauth-callback-server-BXRtD6Fk.js} +2 -2
  33. package/dist/{projection-BzJQncZV.js → projection-B6VS7kbo.js} +156 -49
  34. package/dist/{prompt-Cbq5b4SO.js → prompt-CD11tfG8.js} +3 -3
  35. package/dist/{registry-cbpOxO4M.js → registry-CHewwYEo.js} +1 -1
  36. package/dist/{resolve-t-pmRdwS.js → resolve-1owMH4qo.js} +3 -3
  37. package/dist/{result-DhgjR3nQ.js → result-CEqQFrEf.js} +8 -8
  38. package/dist/{runner-CHv9X9TH.js → runner-BtWvJslp.js} +7 -7
  39. package/dist/{sandbox-egress-signals-Yy3fSCbg.js → sandbox-egress-signals-ByftwJVt.js} +1 -1
  40. package/dist/{schema-TSEisVJR.d.ts → schema-Ct1Zf2xy.d.ts} +16 -0
  41. package/dist/{schema-BhneuGYv.js → schema-D2iGyYIp.js} +11 -0
  42. package/dist/{service-account-C4rBP8ne.js → service-account-BZEuMKdo.js} +3 -3
  43. package/dist/{service-account-DjPIwCMj.js → service-account-DLoeoHww.js} +3 -3
  44. package/dist/{session-stop-DkxI5vc3.js → session-stop-hYNTNpVf.js} +14 -14
  45. package/dist/{skills-BZE2DP8I.js → skills-DXgd5Inh.js} +3 -3
  46. package/dist/{spawn-BvULxIiu.js → spawn-YeqlNDv8.js} +5 -5
  47. package/dist/{state-CO9ETDzk.js → state-C3CbtD_m.js} +2 -2
  48. package/dist/{stop-CL-rdtQb.js → stop-Cze_pEL8.js} +288 -246
  49. package/dist/{store-DgD78_NK.js → store-CZ9vqR4P.js} +3 -3
  50. package/dist/{task-runner-CKOj6xla.js → task-runner-CMiNGsER.js} +274 -250
  51. package/dist/{turn-failure-response-BTSo6SMJ.js → turn-failure-response-pXhZ2wMK.js} +11 -8
  52. package/dist/{validation-CXeYgBzq.js → validation-Du7NdkOR.js} +1 -1
  53. package/dist/{version-AQa7Fr2H.js → version-EN3Wnq-R.js} +1 -1
  54. package/dist/version.js +1 -1
  55. package/dist/{viewer-Bqkb678l.js → viewer-Agxi_o5c.js} +3 -3
  56. package/dist/{warmup-h6u1e9n0.js → warmup-CY2ArYag.js} +251 -103
  57. package/dist/{work-yN_GAuXY.js → work-EA98F0ia.js} +11 -11
  58. package/dist/{worker-Hl7N292I.js → worker-BALVdWbv.js} +6 -6
  59. package/migrations/0101_drop_legacy_columns.sql +12 -0
  60. package/migrations/meta/0101_snapshot.json +4496 -0
  61. package/migrations/meta/_journal.json +7 -0
  62. package/package.json +5 -4
@@ -1,31 +1,31 @@
1
1
  import { g as withActiveSpan, h as startSpan, i as getActiveSpan, m as startInactiveSpan, r as continueTrace, v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { $ as loadTurnCheckpoint, $i as uploadFilesToConversation, $t as extractAssistantText, A as latestConversationMessageSeq, Ar as automationCreatorUserId, B as getAgentContextInputLimitTokens, Ba as SANDBOX_REPOS_ROOT, Bn as getPlugins, Bo as getConfigDefaults, Br as cancelWatch, Ca as consumeSandboxEgressAuthRequiredSignal, Ci as setWorkspaceSnapshot, Cr as requireReviewItemLinks, Di as isStale, Dn as findLegacyWebActorUserId, Ei as hash, En as createUserTokenStore, Fa as PluginToolDeniedError, Fi as resolveBaseUrl, Fr as RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS, G as AuthPausePersistenceError, Ga as sandboxSkillPathResolution, Gi as getSlackMessagePermalink, Gr as findMatchingWatches, Gt as TurnBudgetExceededError, H as PluginCredentialFailureError, Ha as SANDBOX_WORKSPACE_ROOT, Hr as createTimerWatch, I as upsertConversationMessage, Ir as RESOURCE_SUBSCRIPTION_MAX_TTL_MS, J as abandonReplacedPendingAuth, Ja as runNonInteractiveCommand, K as AuthorizationFlowDisabledError, Ka as buildCommandScript, Ki as openSlackDirectMessage, Kr as getWatch, Kt as TurnSliceLimitExceededError, L as calculateContextCompactionTargetTokens, Li as escapeSlackMrkdwnText, Lo as historyItemFromPiMessage, Lr as RESOURCE_WATCH_TOOL_SOURCE, M as normalizeConversationText, Ma as sleep, Mi as deliverOAuthAuthorization, Mo as credentialAuditAttributes, Mr as resolveAssignees, N as recordDeliveredAssistantMessage, Na as tryWorkspaceRepoCheckoutPath, Ni as formatProviderLabel, Nn as createPluginHookRunner, No as credentialAuditSource, Nr as resolveChannelCapabilities, Oa as buildSandboxEgressNetworkPolicy, Oi as ensureDockerDaemon, Oo as defaultTimezone, Or as EVERYONE_ASSIGNEE, Pa as workspaceRepoCheckoutPath, Pr as getSlackToolContext, Q as continuableMessages, Qi as updateSlackMessage, Qt as persistWithRetry, R as getAgentBackgroundCompactionMarkTokens, Ra as SANDBOX_COMMAND_PATH, Rn as getPluginTools, Ro as piMessageFromHistoryItem, Rr as STOP_WATCHING_TOOL_NAME, Sa as clearSandboxEgressSignals, Si as loadSnapshotsForProfile, Sr as requireReviewItemAssignees, T as resolveTaskTitle, Ta as createSandboxEgressCredentialToken, Ti as create, To as createPluginAnnotations, U as createPluginAuthOrchestration, Ua as sandboxSkillDir, Ui as addReactionToMessage, Ur as createWatch, V as createPluginEgress, Va as SANDBOX_SKILLS_ROOT, Vi as slackMention, W as authorizationId, Wa as sandboxSkillFile, Wi as deleteSlackMessage, Wr as deliverWatch, Wt as TURN_LIMIT_WRAP_UP_MESSAGE, X as clearPendingAuth, Xt as isTurnExecutionLimitExceededError, Y as canReusePendingAuthLink, Yi as postSlackMessage, Yt as createTurnLimitGate, Za as canAccessConversation, Zt as CODEMODE_TOOL_NAME, _a as wrapSandboxSetupError, _i as listWorkspaces, _n as TURN_CONTEXT_TAG, _r as canAgentChangeReviewItem, a as loadProjection, ai as getDashboardReviewItemLink, ar as dismissOpenReviewItems, at as failTurnRecord, b as persistConversationMessages, ba as isWorkspaceSnapshotNotReadyError, bi as WorkspaceValidationError, bn as readParentAgentTask, c as recordAgentsInstructionsUpdated, cn as isStandaloneRuntimeContextMessage, cr as insertReviewItem, da as withSlackRetries, dn as normalizeToolNameFromResult, en as getPiMessageRole, eo as readConversationAccessFromSql, f as recordAuthorizationRequested, fi as renderToolResultNudge, fn as retainRuntimeTurnContext, fr as searchReviewItems, g as recordToolExecutionStarted, ga as throwSandboxOperationError, gi as getWorkspaceByName, ha as isAlreadyExistsError, hi as getWorkspace, hn as REQUEST_CONTEXT_SECTION_TAG, hr as PLUGIN_REVIEW_ITEM_KEY_PREFIX, i as loadConversationProjection, ia as getFilePermalink, in as hasTurnInput, j as markConversationMessage, ja as SANDBOX_RUNTIME, jr as resolveAssignee, ka as resolveSandboxCommandEnvironment, ki as getSandboxProvider, kn as getOAuthAccountProviders, ko as resolveUserTimezone, kr as activeParticipantUserIds, l as recordAttachmentsDelivered, la as normalizeSlackConversationId, ln as isToolResultError, m as recordMcpProviderConnected, ma as isAbortError, mi as deleteWorkspace, mn as trimTrailingAssistantMessages, mr as updateReviewItemContent, na as SlackActionError, nn as getUserMessageInstructionText, nt as saveTurnCheckpoint, oa as getSlackClient, on as isAssistantMessage, or as getOpenReviewItemByDedupeKey, ot as getTurnRecord, p as recordGuardianActionReviewed, pi as createWorkspace, pn as stripRuntimeTurnContext, q as AuthorizationPauseError, qa as buildNonInteractiveShellScript, qr as listWatches, qt as TurnToolCallLimitExceededError, r as loadConnectedMcpProviders, ra as downloadPrivateSlackFile, ri as getDashboardConversationLink, rr as closeReviewItem, rt as abandonTurnRecord, sa as isConversationScopedChannel, si as getDashboardTaskLink, sn as isContinuablePiBoundary, sr as getReviewItem, t as commitAcceptedReply, ti as verifyTimerWatchCredentialSubject, tn as getTerminalAssistantMessages, ua as runWithSlackInstallationToken, ui as ToolInputError, un as isToolResultMessage, v as hydrateConversationMessages, va as WorkspaceSnapshotNotReadyError, vr as canReadReviewItem, w as fallbackShortTitle, wa as consumeSandboxEgressPermissionDeniedSignal, wi as setWorkspaceSnapshotBuild, wo as saveObjectAnnotations, xa as workspaceSnapshotNotReadyUserMessage, xi as invalidateReadySnapshot, xr as readReviewItemAgentScope, ya as getWorkspaceSnapshotNotReadyError, yi as updateWorkspace, yo as matchSlackAttachments, z as getAgentContextCompactionTriggerTokens, za as SANDBOX_DATA_ROOT, zi as normalizeSlackReplyMarkdown, zo as projectConversationEvents } from "./projection-BzJQncZV.js";
3
- import { A as estimateTextTokens, B as createAssistantProviderError, D as requestPrefixAttributes, E as resolveGatewayModel, G as isProviderRefusal, H as findProviderError, I as unwrapCurrentInstruction, J as resolveGatewayCredential, K as isProviderRetryError, L as escapeXml, M as COMPACTION_SUMMARY_PREFIX, N as hasCompactedConversationContext, O as estimateMessagesTokens, P as isCompactionSummaryText, U as getProviderErrorAttributes, V as createProviderError, _ as toPiReasoningLevel, b as GEN_AI_SERVER_ADDRESS, g as TURN_REASONING_LEVELS, j as textCharsForTokens, k as estimateRequestOverheadTokens, n as botConfig, q as getGatewayApiKey, v as normalizeSlackEmojiName, y as GEN_AI_PROVIDER_NAME, z as ProviderError } from "./config-DvnTPCfp.js";
4
- import { C as summarizeMessageText, E as withSpan, G as isRecord$4, S as setTags, T as withLogContext, V as runWithLogAttributes, W as normalizeIdentityEmail, _ as runBestEffort, a as extractGenAiUsageSummary, b as setSpanAttributes, d as logAudit, f as logError, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, l as getLogContextAttributesForSpan, m as logInfo, o as getActiveTraceContext, p as logException, q as toOptionalString, u as getTracePropagationHeaders, v as serializeGenAiAttribute, x as setSpanStatus } from "./logging-9OAq-fdg.js";
5
- import { a as toCanonicalInputMessage, c as toGenAiPayloadMetadata, i as runWithConversationPrivacy, l as toGenAiPayloadTraceAttributes, o as toCanonicalOutputMessage, r as resolveConversationPrivacy, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-DPjv4SnA.js";
2
+ import { $ as loadTurnCheckpoint, $i as uploadFilesToConversation, $t as extractAssistantText, A as latestConversationMessageSeq, Ar as automationCreatorUserId, B as getAgentContextInputLimitTokens, Ba as SANDBOX_REPOS_ROOT, Bn as getPlugins, Bo as getConfigDefaults, Br as cancelWatch, Ca as consumeSandboxEgressAuthRequiredSignal, Ci as setWorkspaceSnapshot, Cr as requireReviewItemLinks, Di as isStale, Dn as findLegacyWebActorUserId, Ei as hash, En as createUserTokenStore, Fa as PluginToolDeniedError, Fi as resolveBaseUrl, Fr as RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS, G as AuthPausePersistenceError, Ga as sandboxSkillPathResolution, Gi as getSlackMessagePermalink, Gr as findMatchingWatches, Gt as TurnBudgetExceededError, H as PluginCredentialFailureError, Ha as SANDBOX_WORKSPACE_ROOT, Hr as createTimerWatch, I as upsertConversationMessage, Ir as RESOURCE_SUBSCRIPTION_MAX_TTL_MS, J as abandonReplacedPendingAuth, Ja as runNonInteractiveCommand, K as AuthorizationFlowDisabledError, Ka as buildCommandScript, Ki as openSlackDirectMessage, Kr as getWatch, Kt as TurnSliceLimitExceededError, L as calculateContextCompactionTargetTokens, Li as escapeSlackMrkdwnText, Lo as historyItemFromPiMessage, Lr as RESOURCE_WATCH_TOOL_SOURCE, M as normalizeConversationText, Ma as sleep, Mi as deliverOAuthAuthorization, Mo as credentialAuditAttributes, Mr as resolveAssignees, N as recordDeliveredAssistantMessage, Na as tryWorkspaceRepoCheckoutPath, Ni as formatProviderLabel, Nn as createPluginHookRunner, No as credentialAuditSource, Nr as resolveChannelCapabilities, Oa as buildSandboxEgressNetworkPolicy, Oi as ensureDockerDaemon, Oo as defaultTimezone, Or as EVERYONE_ASSIGNEE, Pa as workspaceRepoCheckoutPath, Pr as getSlackToolContext, Q as continuableMessages, Qi as updateSlackMessage, Qt as persistWithRetry, R as getAgentBackgroundCompactionMarkTokens, Ra as SANDBOX_COMMAND_PATH, Rn as getPluginTools, Ro as piMessageFromHistoryItem, Rr as STOP_WATCHING_TOOL_NAME, Sa as clearSandboxEgressSignals, Si as loadSnapshotsForProfile, Sr as requireReviewItemAssignees, T as resolveTaskTitle, Ta as createSandboxEgressCredentialToken, Ti as create, To as createPluginAnnotations, U as createPluginAuthOrchestration, Ua as sandboxSkillDir, Ui as addReactionToMessage, Ur as createWatch, V as createPluginEgress, Va as SANDBOX_SKILLS_ROOT, Vi as slackMention, W as authorizationId, Wa as sandboxSkillFile, Wi as deleteSlackMessage, Wr as deliverWatch, Wt as TURN_LIMIT_WRAP_UP_MESSAGE, X as clearPendingAuth, Xt as isTurnExecutionLimitExceededError, Y as canReusePendingAuthLink, Yi as postSlackMessage, Yt as createTurnLimitGate, Za as canAccessConversation, Zt as CODEMODE_TOOL_NAME, _a as wrapSandboxSetupError, _i as listWorkspaces, _n as TURN_CONTEXT_TAG, _r as canAgentChangeReviewItem, a as loadProjection, ai as getDashboardReviewItemLink, ar as dismissOpenReviewItems, at as failTurnRecord, b as persistConversationMessages, ba as isWorkspaceSnapshotNotReadyError, bi as WorkspaceValidationError, bn as readParentAgentTask, c as recordAgentsInstructionsUpdated, cn as isStandaloneRuntimeContextMessage, cr as insertReviewItem, da as withSlackRetries, dn as normalizeToolNameFromResult, en as getPiMessageRole, eo as readConversationAccessFromSql, f as recordAuthorizationRequested, fi as renderToolResultNudge, fn as retainRuntimeTurnContext, fr as searchReviewItems, g as recordToolExecutionStarted, ga as throwSandboxOperationError, gi as getWorkspaceByName, ha as isAlreadyExistsError, hi as getWorkspace, hn as REQUEST_CONTEXT_SECTION_TAG, hr as PLUGIN_REVIEW_ITEM_KEY_PREFIX, i as loadConversationProjection, ia as getFilePermalink, in as hasTurnInput, j as markConversationMessage, ja as SANDBOX_RUNTIME, jr as resolveAssignee, ka as resolveSandboxCommandEnvironment, ki as getSandboxProvider, kn as getOAuthAccountProviders, ko as resolveUserTimezone, kr as activeParticipantUserIds, l as recordAttachmentsDelivered, la as normalizeSlackConversationId, ln as isToolResultError, m as recordMcpProviderConnected, ma as isAbortError, mi as deleteWorkspace, mn as trimTrailingAssistantMessages, mr as updateReviewItemContent, na as SlackActionError, nn as getUserMessageInstructionText, nt as saveTurnCheckpoint, oa as getSlackClient, on as isAssistantMessage, or as getOpenReviewItemByDedupeKey, ot as getTurnRecord, p as recordGuardianActionReviewed, pi as createWorkspace, pn as stripRuntimeTurnContext, q as AuthorizationPauseError, qa as buildNonInteractiveShellScript, qr as listWatches, qt as TurnToolCallLimitExceededError, r as loadConnectedMcpProviders, ra as downloadPrivateSlackFile, ri as getDashboardConversationLink, rr as closeReviewItem, rt as abandonTurnRecord, sa as isConversationScopedChannel, si as getDashboardTaskLink, sn as isContinuablePiBoundary, sr as getReviewItem, t as commitAcceptedReply, ti as verifyTimerWatchCredentialSubject, tn as getTerminalAssistantMessages, ua as runWithSlackInstallationToken, ui as ToolInputError, un as isToolResultMessage, v as hydrateConversationMessages, va as WorkspaceSnapshotNotReadyError, vr as canReadReviewItem, w as fallbackShortTitle, wa as consumeSandboxEgressPermissionDeniedSignal, wi as setWorkspaceSnapshotBuild, wo as saveObjectAnnotations, xa as workspaceSnapshotNotReadyUserMessage, xi as invalidateReadySnapshot, xr as readReviewItemAgentScope, ya as getWorkspaceSnapshotNotReadyError, yi as updateWorkspace, yo as matchSlackAttachments, z as getAgentContextCompactionTriggerTokens, za as SANDBOX_DATA_ROOT, zi as normalizeSlackReplyMarkdown, zo as projectConversationEvents } from "./projection-B6VS7kbo.js";
3
+ import { A as estimateTextTokens, B as createAssistantProviderError, D as requestPrefixAttributes, E as resolveGatewayModel, G as isProviderRefusal, H as findProviderError, I as unwrapCurrentInstruction, J as resolveGatewayCredential, K as isProviderRetryError, L as escapeXml, M as COMPACTION_SUMMARY_PREFIX, N as hasCompactedConversationContext, O as estimateMessagesTokens, P as isCompactionSummaryText, U as getProviderErrorAttributes, V as createProviderError, _ as toPiReasoningLevel, b as GEN_AI_SERVER_ADDRESS, g as TURN_REASONING_LEVELS, j as textCharsForTokens, k as estimateRequestOverheadTokens, n as botConfig, q as getGatewayApiKey, v as normalizeSlackEmojiName, y as GEN_AI_PROVIDER_NAME, z as ProviderError } from "./config-CCPHvTqx.js";
4
+ import { C as summarizeMessageText, E as withSpan, G as isRecord$4, S as setTags, T as withLogContext, V as runWithLogAttributes, W as normalizeIdentityEmail, _ as runBestEffort, a as extractGenAiUsageSummary, b as setSpanAttributes, d as logAudit, f as logError, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, l as getLogContextAttributesForSpan, m as logInfo, o as getActiveTraceContext, p as logException, q as toOptionalString, u as getTracePropagationHeaders, v as serializeGenAiAttribute, x as setSpanStatus } from "./logging-D0svFM8r.js";
5
+ import { a as toCanonicalInputMessage, c as toGenAiPayloadMetadata, i as runWithConversationPrivacy, l as toGenAiPayloadTraceAttributes, o as toCanonicalOutputMessage, r as resolveConversationPrivacy, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-CZD5soDW.js";
6
6
  import { d as parseSlackChannelReferenceId, f as parseSlackTeamId, h as parseSlackMessageTs, n as createSlackActor, o as isUserActor, p as parseSlackUserId, u as parseSlackChannelId } from "./actor-6jsm_v96.js";
7
- import { D as turnBehavior, J as agentTurnCostUsd, M as SYSTEM_IDENTITY_ID, O as conversationKindFromRow, P as resolveActorIdentityId, Q as resolveRootConversationId$1, T as isTopLevelKind, Z as hasAgentTurnUsage, _ as setArchivedAt, a as getConversationStore, c as conversationIdsWithAnnotation, et as conversationDetailTouch, g as readConversationTrees, h as conversationDescendants, i as getConversationMessageSearchStore, it as parseDestination, l as hasAnnotationKey, m as conversationAncestors, nt as touchConversationDetail, o as getDb, ot as sameDestination, q as addAgentTurnUsage, r as getConversationEventStore, s as getSqlExecutor, tt as nextDetailVersion, u as treeHasAnnotationKey, w as isPersonInput } from "./db-Dts2XvLu.js";
8
- import { A as juniorConversations, M as juniorUsers, N as juniorDestinations, P as juniorArtifacts, _ as juniorConversationReadPositions, b as juniorConversationBriefs, c as juniorReviewItemSlackCards, f as juniorAutomations, g as juniorAgentInvocations, h as juniorAgentBindings, j as juniorIdentities, k as juniorAttachments, p as juniorStats, u as juniorAutomationRuns, v as juniorConversationParticipants, w as juniorConversationEvents } from "./executor-Ck73J0wP.js";
7
+ import { D as turnBehavior, J as agentTurnCostUsd, M as SYSTEM_IDENTITY_ID, O as conversationKindFromRow, P as resolveActorIdentityId, Q as resolveRootConversationId$1, T as isTopLevelKind, Z as hasAgentTurnUsage, _ as setArchivedAt, a as getConversationStore, c as conversationIdsWithAnnotation, et as conversationDetailTouch, g as readConversationTrees, h as conversationDescendants, i as getConversationMessageSearchStore, it as parseDestination, l as hasAnnotationKey, m as conversationAncestors, nt as touchConversationDetail, o as getDb, ot as sameDestination, q as addAgentTurnUsage, r as getConversationEventStore, s as getSqlExecutor, tt as nextDetailVersion, u as treeHasAnnotationKey, w as isPersonInput } from "./db-C1M1y-bh.js";
8
+ import { A as juniorConversations, M as juniorUsers, N as juniorDestinations, P as juniorArtifacts, _ as juniorConversationReadPositions, b as juniorConversationBriefs, c as juniorReviewItemSlackCards, f as juniorAutomations, g as juniorAgentInvocations, h as juniorAgentBindings, j as juniorIdentities, k as juniorAttachments, p as juniorStats, u as juniorAutomationRuns, v as juniorConversationParticipants, w as juniorConversationEvents } from "./executor-DUSEwXaO.js";
9
9
  import { _ as instructionProvenanceFor, a as KNOWN_CONVERSATION_EVENT_TYPES, g as instructionActors, h as contextProvenance, r as detectImageMediaType, v as sameActorIdentity } from "./media-BepyEUNm.js";
10
10
  import { a as listReferenceFiles } from "./package-discovery-DJhGdS4c.js";
11
- import { c as fetchWithBoundedOAuthErrorBodies, d as actorLogContext, f as credentialContextForActor, g as credentialUserSubjectId, i as resolvePluginHeaderEnvRefs, l as getOAuthProviderErrorAttributes, s as OAuthProviderError } from "./registry-cbpOxO4M.js";
12
- import { n as pluginCatalogRuntime } from "./catalog-runtime-DgouZKZm.js";
13
- import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-BZE2DP8I.js";
14
- import { l as completeObject, o as isEventConversationMessage, r as EVENT_AUTHOR_ID, u as completeText } from "./prompt-Cbq5b4SO.js";
11
+ import { c as fetchWithBoundedOAuthErrorBodies, d as actorLogContext, f as credentialContextForActor, g as credentialUserSubjectId, i as resolvePluginHeaderEnvRefs, l as getOAuthProviderErrorAttributes, s as OAuthProviderError } from "./registry-CHewwYEo.js";
12
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-CpCmlD9L.js";
13
+ import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-DXgd5Inh.js";
14
+ import { l as completeObject, o as isEventConversationMessage, r as EVENT_AUTHOR_ID, u as completeText } from "./prompt-CD11tfG8.js";
15
15
  import { a as withLock, i as fenceLock } from "./locks-D-0h111u.js";
16
- import { a as readActorIdentityFromSql, f as identityAvatarUrl, h as readUserAvatarUrls, i as readActorIdentity } from "./viewer-Bqkb678l.js";
17
- import { a as getStateAdapter, n as readEncryptedState, t as createEncryptedState } from "./state-CO9ETDzk.js";
16
+ import { a as readActorIdentityFromSql, f as identityAvatarUrl, h as readUserAvatarUrls, i as readActorIdentity } from "./viewer-Agxi_o5c.js";
17
+ import { a as getStateAdapter, n as readEncryptedState, t as createEncryptedState } from "./state-C3CbtD_m.js";
18
18
  import { i as getFirstRunAtMs, o as getZonedDateTimeParts, s as isValidTimeZone } from "./schedule-cP0AACm1.js";
19
19
  import { G as briefLinkSchema, K as briefOutcomeStatusSchema, R as removedCardSchema, U as readMessageAttachments, X as parseStoredBrief } from "./conversation-CMkSmi02.js";
20
- import { A as findLegacyNoReplyMarker, C as readAutomationResult, D as getAssistantReplyText, E as decideReply, M as readNoReply, N as REPORT_BLOCKED_TOOL_NAME, O as sanitizeAssistantText, P as readBlockedReport, b as FINISH_AUTOMATION_RUN_TOOL_NAME, i as createCacheWarmingRecorder, j as isLegacyNoReplyMarker, k as NO_REPLY_TOOL_NAME, l as readLastUserMessageAtByConversation, v as JUNIOR_PERSONALITY, w as remindMissingAutomationResult, x as automationResultSchema$1 } from "./warmup-h6u1e9n0.js";
21
- import { D as QUEUE_SIGNATURE_MAX_AGE_MS, g as getVercelConversationWorkQueue, k as getTurnRequestDeadline, m as sendWorkspaceSnapshotJob, n as backgroundCompactionId, p as sendNextWorkspaceSnapshotJob } from "./background-compaction-queue-DUkHZjmL.js";
22
- import { B as AGENT_TYPES, C as isTerminalAgentInvocation, F as CHILD_AGENT_RESULTS, I as PARENT_AGENT_TARGET, J as getAgentInvocationMessageId, P as CHILD_AGENT_KINDS, R as agentNameSchema, S as invocationFromRow, T as listOpenAgentInvocations, U as formatAgentTypes, Z as getChildAgentLockName, at as getConversationTurnBoundaryError, dt as markTurnFailed, et as parseAgentInvocationResultMessageId, f as ConversationTurnLifecycleService, ft as startActiveTurn, g as NON_TERMINAL_AGENT_INVOCATION_STATUSES, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, lt as markTurnClosed, m as loadPendingMessageCards, mt as buildDeterministicTurnId, nt as CooperativeTurnYieldError, o as getTurnUserMessage, q as getAgentInvocationIdForResult, rt as TurnInputCommitLostError, st as isTurnInputCommitLostError, t as finalizeFailedTurnReplyWithEvent, u as buildTurnThreadContext, w as listAgentInvocationsForConversation, x as getLatestAgentInvocationForConversation } from "./turn-failure-response-BTSo6SMJ.js";
23
- import { $ as withoutSavedSteeringMessages, A as requireSlackChannelMessageScope, B as maybePostAutomatedTurnLimitNotice, C as enqueueEventNotification, D as timerWatchCredentialSubject, E as renderEventBatchInputs, F as WORKSPACE_SNAPSHOT_FAILED_EVENT, H as resolveSlackReplyTarget, I as WORKSPACE_SNAPSHOT_READY_EVENT, J as assemblePrompt, K as recordFinishedTurnForAutomatedLimit, L as workspaceSnapshotFinishedEvent, O as getEventCatalog, P as slackChannelMessageTrigger, Q as loadPromptTurnContext, R as workspaceSnapshotWatch, S as EVENT_WAIT_MS, T as isEventMailboxMetadata, X as buildSteeringPiMessage, Y as buildPromptInput, Z as instructionForInputs, _ as sourceFromTurnInput, at as addConversationNote, b as conversationSubtree, c as loadReviewItemInput, d as getAuthPausedConversationTurnId, f as getEventBatchDelayMs, p as listActiveMailboxTurns, r as markConversationsStopped, rt as isExperimentalFeatureEnabled, s as eventReviewItemInputs, t as getConversationStoppedAtMs, tt as saveUserCustomization, v as turnInputFactsFromConversationMessage, w as eventBatchMessageMeta, x as conversationSubtreeColumns, y as legacyWebMailboxMetadataSchema } from "./session-stop-DkxI5vc3.js";
20
+ import { A as readNoReply, C as replyTextSchema, D as NO_REPLY_TOOL_NAME, E as sanitizeAssistantText, M as readBlockedReport, O as findLegacyNoReplyMarker, S as remindMissingAnswer, T as getAssistantReplyText, b as REPLY_TOOL_NAME, i as createCacheWarmingRecorder, j as REPORT_BLOCKED_TOOL_NAME, k as isLegacyNoReplyMarker, l as readLastUserMessageAtByConversation, v as JUNIOR_PERSONALITY, w as decideReply, x as readTurnAnswer } from "./warmup-CY2ArYag.js";
21
+ import { D as QUEUE_SIGNATURE_MAX_AGE_MS, g as getVercelConversationWorkQueue, k as getTurnRequestDeadline, m as sendWorkspaceSnapshotJob, n as backgroundCompactionId, p as sendNextWorkspaceSnapshotJob } from "./background-compaction-queue-Cre1wFt9.js";
22
+ import { B as AGENT_TYPES, C as isTerminalAgentInvocation, F as CHILD_AGENT_RESULTS, I as PARENT_AGENT_TARGET, J as getAgentInvocationMessageId, P as CHILD_AGENT_KINDS, R as agentNameSchema, S as invocationFromRow, T as listOpenAgentInvocations, U as formatAgentTypes, Z as getChildAgentLockName, at as getConversationTurnBoundaryError, dt as markTurnFailed, et as parseAgentInvocationResultMessageId, f as ConversationTurnLifecycleService, ft as startActiveTurn, g as NON_TERMINAL_AGENT_INVOCATION_STATUSES, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, lt as markTurnClosed, m as loadPendingMessageCards, mt as buildDeterministicTurnId, nt as CooperativeTurnYieldError, o as getTurnUserMessage, q as getAgentInvocationIdForResult, rt as TurnInputCommitLostError, st as isTurnInputCommitLostError, t as finalizeFailedTurnReplyWithEvent, u as buildTurnThreadContext, w as listAgentInvocationsForConversation, x as getLatestAgentInvocationForConversation } from "./turn-failure-response-pXhZ2wMK.js";
23
+ import { $ as withoutSavedSteeringMessages, A as requireSlackChannelMessageScope, B as maybePostAutomatedTurnLimitNotice, C as enqueueEventNotification, D as timerWatchCredentialSubject, E as renderEventBatchInputs, F as WORKSPACE_SNAPSHOT_FAILED_EVENT, H as resolveSlackReplyTarget, I as WORKSPACE_SNAPSHOT_READY_EVENT, J as assemblePrompt, K as recordFinishedTurnForAutomatedLimit, L as workspaceSnapshotFinishedEvent, O as getEventCatalog, P as slackChannelMessageTrigger, Q as loadPromptTurnContext, R as workspaceSnapshotWatch, S as EVENT_WAIT_MS, T as isEventMailboxMetadata, X as buildSteeringPiMessage, Y as buildPromptInput, Z as instructionForInputs, _ as sourceFromTurnInput, at as addConversationNote, b as conversationSubtree, c as loadReviewItemInput, d as getAuthPausedConversationTurnId, f as getEventBatchDelayMs, p as listActiveMailboxTurns, r as markConversationsStopped, rt as isExperimentalFeatureEnabled, s as eventReviewItemInputs, t as getConversationStoppedAtMs, tt as saveUserCustomization, v as turnInputFactsFromConversationMessage, w as eventBatchMessageMeta, x as conversationSubtreeColumns, y as legacyWebMailboxMetadataSchema } from "./session-stop-hYNTNpVf.js";
24
24
  import { D as userCustomizationTextSchema, T as USER_CUSTOMIZATION_MAX_CHARS, _ as buttonUserInputField, b as normalizeUserInputAnswer, g as USER_INPUT_NOTE, h as USER_INPUT_LIMITS, m as apiErrorSchema, p as webMessageId, s as sumUtcHoursIntoSixHours, v as formatUserInputAnswer, w as AGENT_INVOCATION_STATUSES, x as userInputRequestSchema } from "./reporting-window-B3Ze-Qnt.js";
25
- import { a as setSnapshotSpanAttributes, i as postinstall, n as resolve$1, r as dependencies, s as getSandboxResources } from "./resolve-t-pmRdwS.js";
26
- import { S as requestConversationWork, T as stopConversationWork, g as getConversationWorkState, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage } from "./store-DgD78_NK.js";
27
- import { $ as readAutomationExecutionByConversationId, At as requireValidEventTrigger, B as setEventAutomationStatus, C as deleteScheduledAutomation, Ct as eventWatchUnavailable, D as saveScheduledAutomation, Dt as registeredEventTypeSchema, E as readScheduledAutomation, Et as registeredEventTriggerProblems, G as listAutomationVersions, I as getEventAutomation, K as readAutomationVersion, L as listDeletedEventAutomationsCreatedBy, N as createEventAutomation, Ot as registeredResourceTypeSchema, P as deleteEventAutomation, R as parseEventAutomationRow, S as createScheduledAutomation, St as eventNamespaceSchema, T as parseScheduledAutomationRow, Tt as registeredEventMatchSchema, U as automationDefinition, X as requireAutomationRevision, Y as automationRevision, Z as emptyAutomationRunWindows, d as getDispatchRecord, et as readAutomationExecutionStatusDays, ft as getPersistedSandboxState, gt as coerceThreadConversationState, ht as persistThreadStateById, it as readAutomationRuns, kt as requireEventIdentifier, l as getDispatchIdForConversation, lt as resolveConversationRouting, n as scheduleSessionCompletedPluginTasks, nt as readAutomationExecutionSummaries, pt as getPersistedThreadState, q as sameDefinitionValue, rt as readAutomationExecutions, t as processPluginTask, tt as readAutomationExecutionStatusHours, u as getDispatchInputMessageId, ut as resolveTurnSessionRouting, vt as automationEventCatalog, wt as hasEventCatalogEntries, yt as describeRegisteredEventTrigger, z as saveEventAutomation } from "./task-runner-CKOj6xla.js";
28
- import { _ as getMcpProviderErrorAttributes, a as serviceAccountOnly, c as createMcpServiceAccountClientProvider, d as PluginMcpClient, f as McpProviderError, g as getMcpAwareTelemetryMessage, h as getMcpAwareErrorType, i as serviceAccountAllows, l as getMcpServiceAccountCredentials, m as McpToolError, p as McpServiceAccountRequiredError, u as McpAuthorizationRequiredError, v as toMcpProviderError } from "./service-account-DjPIwCMj.js";
25
+ import { a as setSnapshotSpanAttributes, i as postinstall, n as resolve$1, r as dependencies, s as getSandboxResources } from "./resolve-1owMH4qo.js";
26
+ import { S as requestConversationWork, T as stopConversationWork, g as getConversationWorkState, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage } from "./store-CZ9vqR4P.js";
27
+ import { A as blockScheduledAutomation, At as registeredResourceTypeSchema, B as blockEventAutomation, Dt as registeredEventMatchSchema, Et as hasEventCatalogEntries, F as readScheduledAutomation, G as getEventAutomation, H as createEventAutomation, I as saveScheduledAutomation, J as saveEventAutomation, K as listDeletedEventAutomationsCreatedBy, M as deleteScheduledAutomation, Mt as requireValidEventTrigger, Ot as registeredEventTriggerProblems, P as parseScheduledAutomationRow, Q as automationDefinition, Tt as eventWatchUnavailable, U as deleteEventAutomation, Y as setEventAutomationStatus, _ as getDispatchIdForConversation, a as resolveTurnSessionRouting, at as requireAutomationRevision, bt as automationEventCatalog, c as getPersistedThreadState, ct as readAutomationExecutionByConversationId, d as coerceThreadConversationState, dt as readAutomationExecutionSummaries, et as listAutomationVersions, ft as readAutomationExecutions, i as resolveConversationRouting, it as automationRevision, j as createScheduledAutomation, jt as requireEventIdentifier, k as notifyAutomationBlocked, kt as registeredEventTypeSchema, lt as readAutomationExecutionStatusDays, n as scheduleSessionCompletedPluginTasks, nt as sameDefinitionValue, ot as emptyAutomationRunWindows, pt as readAutomationRuns, q as parseEventAutomationRow, s as getPersistedSandboxState, t as processPluginTask, tt as readAutomationVersion, u as persistThreadStateById, ut as readAutomationExecutionStatusHours, v as getDispatchInputMessageId, wt as eventNamespaceSchema, xt as describeRegisteredEventTrigger, y as getDispatchRecord } from "./task-runner-CMiNGsER.js";
28
+ import { _ as getMcpProviderErrorAttributes, a as serviceAccountOnly, c as createMcpServiceAccountClientProvider, d as PluginMcpClient, f as McpProviderError, g as getMcpAwareTelemetryMessage, h as getMcpAwareErrorType, i as serviceAccountAllows, l as getMcpServiceAccountCredentials, m as McpToolError, p as McpServiceAccountRequiredError, u as McpAuthorizationRequiredError, v as toMcpProviderError } from "./service-account-DLoeoHww.js";
29
29
  import { A as eventAutomationTriggerSchema, D as automationTitleSchema, E as automationInstructionToolSchema, F as compileScheduleIntent, H as automationTaskSchema, I as scheduleIntentFromTool, L as toolScheduleIntentSchema, O as taskOutcomeInputSchema, P as ScheduleIntentError, R as weekdaySchema, T as automationContextToolSchema, U as automationTaskText, V as automationTaskDescription, j as SCHEDULED_AUTOMATION_SYSTEM_ACTOR, l as automationListQuerySchema, z as automationSkillNameSchema } from "./automation-yJX3C7i3.js";
30
30
  import { n as privateTraceResultAttributes } from "./private-trace-result-CE7_lEdq.js";
31
31
  import { streamSimple } from "@earendil-works/pi-ai/compat";
@@ -790,13 +790,15 @@ function relayStream(source, onEvent) {
790
790
  *
791
791
  * The base argument exists so tests can inject a stub stream function.
792
792
  * `promptName` names a request that is not an agent loop call, such as a
793
- * context summary.
793
+ * context summary. `endAttributes` adds caller attributes from the final
794
+ * message.
794
795
  */
795
796
  function createTracedStreamFn(baseOrOptions = streamSimple) {
796
797
  const base = typeof baseOrOptions === "function" ? baseOrOptions : baseOrOptions.base ?? streamSimple;
797
798
  const mode = attributeModeForPrivacy(typeof baseOrOptions === "function" ? void 0 : baseOrOptions.conversationPrivacy);
798
799
  const effectivePrivacy = (typeof baseOrOptions === "function" ? void 0 : baseOrOptions.conversationPrivacy) ?? "private";
799
800
  const promptName = typeof baseOrOptions === "function" ? void 0 : baseOrOptions.promptName;
801
+ const callerEndAttributes = typeof baseOrOptions === "function" ? void 0 : baseOrOptions.endAttributes;
800
802
  return async (model, context, options) => {
801
803
  const span = startInactiveSpan({
802
804
  name: `chat ${model.id}`,
@@ -815,7 +817,8 @@ function createTracedStreamFn(baseOrOptions = streamSimple) {
815
817
  try {
816
818
  const endAttributes = {
817
819
  ...buildChatEndAttributes(finalMessage, mode),
818
- ...responseTiming.attributes()
820
+ ...responseTiming.attributes(),
821
+ ...callerEndAttributes?.(finalMessage)
819
822
  };
820
823
  for (const [key, value] of Object.entries(endAttributes)) span.setAttribute(key, value);
821
824
  if (finalMessage.stopReason === "error") {
@@ -856,7 +859,7 @@ function shouldEmitDevAgentTrace() {
856
859
  // src/chat/services/turn-result.ts
857
860
  /** Process raw agent messages into a structured AgentRunResult. */
858
861
  function buildTurnResult(input) {
859
- if (input.requireAutomationResult) return buildAutomationTurnResult(input);
862
+ if (input.answer) return buildGatedTurnResult(input, input.answer);
860
863
  const { newMessages, sandboxRef, shouldTrace } = input;
861
864
  const toolResults = newMessages.filter(isToolResultMessage);
862
865
  const assistantMessages = newMessages.filter(isAssistantMessage);
@@ -940,29 +943,40 @@ function buildDiagnostics(input, result) {
940
943
  }) : void 0
941
944
  };
942
945
  }
946
+ /** Name of a Turn answer in telemetry. */
947
+ function answerName(answer) {
948
+ if (answer === "missing") return "missing";
949
+ if ("reply" in answer) return "reply";
950
+ if ("noReply" in answer) return "noReply";
951
+ return "reportBlocked";
952
+ }
943
953
  /**
944
- * Build the result of an Automation run from its declared result. Final
945
- * assistant text is not used. A run without a declared result fails.
954
+ * Build the result of a gated Turn from its answer. Final assistant text is
955
+ * not used. A Turn without an answer posts nothing.
946
956
  */
947
- function buildAutomationTurnResult(input) {
957
+ function buildGatedTurnResult(input, answer) {
948
958
  const lastAssistant = input.newMessages.filter(isAssistantMessage).at(-1);
949
959
  const stopReason = lastAssistant?.stopReason;
950
- const automation = readAutomationResult(input.piMessages ?? input.newMessages);
951
- const outcome = automation ? "success" : stopReason === "error" ? "provider_error" : "execution_failure";
952
- const errorMessage = outcome === "provider_error" ? lastAssistant?.errorMessage : outcome === "execution_failure" ? "Automation run ended without a declared result." : void 0;
960
+ const answered = answer !== "missing";
961
+ const outcome = answered ? "success" : stopReason === "error" ? "provider_error" : input.missingAnswerFails ? "execution_failure" : "success";
962
+ const errorMessage = outcome === "provider_error" ? lastAssistant?.errorMessage : outcome === "execution_failure" ? "Automation run ended without an answer." : void 0;
963
+ const reply = answered && "reply" in answer ? answer.reply : void 0;
964
+ if (!answered && stopReason !== "error") logWarn("agent.turn.answer.missing", {});
953
965
  if (input.shouldTrace) logInfo("agent.message.generated", {
954
- "app.message.kind": "automation_result",
966
+ "app.message.kind": "turn_answer",
955
967
  "app.ai.outcome": outcome,
956
- "app.automation.result": automation?.result ?? "missing"
968
+ "app.turn.answer": answerName(answer)
957
969
  });
958
970
  return {
959
- text: automation?.result === "send_message" ? automation.message : "",
960
- ...automation ? { automation } : void 0,
971
+ text: reply?.text ?? "",
972
+ ...reply ? { reply } : void 0,
973
+ ...answered && "noReply" in answer ? { noReply: answer.noReply } : void 0,
974
+ ...answered && "blocked" in answer ? { blocked: answer.blocked } : void 0,
961
975
  sandboxRef: input.sandboxRef,
962
976
  piMessages: input.piMessages,
963
977
  diagnostics: buildDiagnostics(input, {
964
978
  outcome,
965
- usedPrimaryText: automation?.result === "send_message",
979
+ usedPrimaryText: Boolean(reply),
966
980
  stopReason,
967
981
  errorMessage,
968
982
  lastAssistant
@@ -1302,14 +1316,14 @@ function restoreToolActionRejections(messages) {
1302
1316
  return priorRejections;
1303
1317
  }
1304
1318
  // src/chat/agent/action-confirmation-retry.ts
1305
- const RUN_ENDING_TOOL_NAMES = /* @__PURE__ */ new Set([FINISH_AUTOMATION_RUN_TOOL_NAME, REPORT_BLOCKED_TOOL_NAME]);
1319
+ const RUN_ENDING_TOOL_NAMES = /* @__PURE__ */ new Set([REPLY_TOOL_NAME, REPORT_BLOCKED_TOOL_NAME]);
1306
1320
  function endsRun(message) {
1307
1321
  return isToolResultMessage(message) && !isToolResultError(message) && RUN_ENDING_TOOL_NAMES.has(normalizeToolNameFromResult(message) ?? "");
1308
1322
  }
1309
1323
  /**
1310
1324
  * Return the durable tool-result boundary for one additional agent
1311
1325
  * continuation when an ask rejection has no destination-visible reply. A run
1312
- * that a blocked report or an Automation result ended gets none.
1326
+ * that a blocked report or a `reply` call ended gets none.
1313
1327
  */
1314
1328
  function actionConfirmationRetryMessages(messages) {
1315
1329
  let rejectionIndex = -1;
@@ -5964,7 +5978,8 @@ function createSpawnAgentTool(spawnAgent, titleCost) {
5964
5978
  "Delegate a Task when: the request splits into independent tracks that each need real investigation, such as several repos, services, sources, or items (start every track in the same message); an answer needs reading across many files, logs, or sources and you need the conclusion, not the raw output; a side task does not block your main answer; or you want a second opinion that is not anchored on your analysis (give it the evidence, not your conclusion).",
5965
5979
  "Do it yourself instead of a Task when: the work fits in a handful of tool calls; you already know the file, symbol, or value to look up; or the job is one modest task that you would only split into pieces. Each child rebuilds its context and its result arrives in a later turn, so when in doubt, do not spawn a Task.",
5966
5980
  `Pick agent_type when one fits; omit it for a fresh general-purpose child with your tools:\n${formatAgentTypes()}`,
5967
- "After you delegate, do not do the same work yourself. End your turn with a short status. You know nothing about a child's findings until its result arrives: do not predict them, do not wait or poll, and if the user asks before then, give status.",
5981
+ `After you delegate, do not do the same work yourself. When your reply posts to people, do not post a status that only says the work started or repeats the task: call ${NO_REPLY_TOOL_NAME} instead, because the child's result posts when it arrives. Reply only with something people need now, such as an answer, a question, or a Thread's dashboard_url.`,
5982
+ "You know nothing about a child's findings until its result arrives: do not predict them, do not wait or poll, and if the user asks before then, give status.",
5968
5983
  "Give a child a name when you may send it more work later. To give more work to a child agent that already exists, use messageAgent instead.",
5969
5984
  "A child keeps its type and kind when it receives more work through messageAgent.",
5970
5985
  "Your task text is the child's instruction. Its action review judges the child's actions against that text, so name only actions that your own conversation backs, with the exact target."
@@ -6022,6 +6037,42 @@ function createSpawnAgentTool(spawnAgent, titleCost) {
6022
6037
  }
6023
6038
  });
6024
6039
  }
6040
+ // src/chat/automations/block-run.ts
6041
+ /**
6042
+ * Find the Automation of a run. The SQL run row lasts as long as the
6043
+ * Automation, but a Watch can outlive the dispatch record. The dispatch record
6044
+ * covers a run whose row does not link its Conversation yet.
6045
+ */
6046
+ async function findRunAutomation(conversationId, dispatchId) {
6047
+ const run = await readAutomationExecutionByConversationId({ conversationId });
6048
+ if (run) return run;
6049
+ const source = dispatchId ? (await getDispatchRecord(dispatchId))?.source : void 0;
6050
+ if (!source || !("automationId" in source) || !source.automationId) return;
6051
+ return {
6052
+ automationId: source.automationId,
6053
+ kind: source.kind === "scheduled_automation" ? "scheduled" : "event"
6054
+ };
6055
+ }
6056
+ /**
6057
+ * Block the Automation of a run from a later Turn of the run, such as a Watch
6058
+ * Event or child result Turn. The dispatch Turn blocks through its dispatch
6059
+ * outcome. Its creator is told when the block is first stored.
6060
+ */
6061
+ async function blockRunAutomation(conversationId, blocked) {
6062
+ const dispatchId = getDispatchIdForConversation(conversationId);
6063
+ const automation = await findRunAutomation(conversationId, dispatchId);
6064
+ if (!automation) {
6065
+ logWarn("automation.block.unresolved", { "gen_ai.conversation.id": conversationId });
6066
+ return;
6067
+ }
6068
+ const { automationId, kind } = automation;
6069
+ if (kind === "scheduled" ? await blockScheduledAutomation(getDb(), automationId, blocked.missing) : await blockEventAutomation(getDb(), automationId, blocked.missing)) await notifyAutomationBlocked({
6070
+ automationId,
6071
+ ...dispatchId ? { dispatchId } : void 0,
6072
+ kind,
6073
+ reason: blocked.missing
6074
+ });
6075
+ }
6025
6076
  // src/chat/conversations/delivery-pause.ts
6026
6077
  /** True when the Conversation is a root that delivers to a Location. */
6027
6078
  function canPauseConversationDelivery(conversation) {
@@ -6148,16 +6199,32 @@ async function measureTurnCompactionWait(setTurnAttributes, callback) {
6148
6199
  }
6149
6200
  }
6150
6201
  /**
6151
- * Log the provider-reported input of the first model request after a
6152
- * replacement. It shows when the replacement was still above the threshold.
6202
+ * Track the replacement that waits for the provider-reported input of the
6203
+ * next model request. That request's `gen_ai.chat` span shows whether the
6204
+ * replacement got the history below the threshold. Production drops info
6205
+ * logs, so this is a span attribute.
6153
6206
  */
6154
- function logInputAfterCompaction(args) {
6155
- logInfo("context_compaction.next_request.completed", {
6156
- "app.compaction.mode": args.mode,
6157
- "app.compaction.next_input.size": args.inputSize,
6158
- "app.compaction.next_input.over_threshold": args.inputSize > args.threshold,
6159
- "app.compaction.threshold": args.threshold
6160
- });
6207
+ function createNextInputTracker() {
6208
+ let pending;
6209
+ return {
6210
+ replaced(mode, threshold) {
6211
+ pending = {
6212
+ mode,
6213
+ threshold
6214
+ };
6215
+ },
6216
+ attributes(inputSize) {
6217
+ if (!pending || !inputSize) return;
6218
+ const { mode, threshold } = pending;
6219
+ pending = void 0;
6220
+ return {
6221
+ "app.compaction.mode": mode,
6222
+ "app.compaction.next_input.size": inputSize,
6223
+ "app.compaction.next_input.over_threshold": inputSize > threshold,
6224
+ "app.compaction.threshold": threshold
6225
+ };
6226
+ }
6227
+ };
6161
6228
  }
6162
6229
  // src/chat/task-execution/turn-telemetry.ts
6163
6230
  /** Read the turn input timing facts from a mailbox batch, oldest first. */
@@ -6838,12 +6905,12 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
6838
6905
  const disabledFeatures = webActor ? [] : ["interactive-auth"];
6839
6906
  const conversationLocation = storedConversation?.location;
6840
6907
  const isEventTurn = source.kind === "event" || savedMessageIsEvent;
6841
- const deliverToProvider = Boolean(conversationLocation) && isEventTurn && turnBehavior({
6908
+ const postsToProvider = Boolean(conversationLocation) && isEventTurn;
6909
+ const deliverToProvider = postsToProvider && turnBehavior({
6842
6910
  kind: storedConversation?.kind ?? "root",
6843
- personInput: false,
6844
- automationRun: false
6911
+ personInput: false
6845
6912
  }).delivery === "location";
6846
- const surface = deliverToProvider ? "slack" : "api";
6913
+ const surface = postsToProvider ? "slack" : "api";
6847
6914
  const inputTelemetry = resolved.kind === "mailbox" ? turnInputTelemetry(resolved.batch.map((entry) => entry.message)) : void 0;
6848
6915
  const turnTrace = inputTelemetry ?? (savedTurn?.traceContext ? { traceContexts: [savedTurn.traceContext] } : void 0);
6849
6916
  return await withTurnSpan({
@@ -6940,7 +7007,7 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
6940
7007
  const cards = await loadPendingMessageCards(context.conversationId);
6941
7008
  const quiet = options?.quiet === true && isEventTurn && cards.length === 0;
6942
7009
  let deliveryResult;
6943
- if (deliverToProvider && !quiet && !await isConversationDeliveryPaused(context.conversationId)) {
7010
+ if ((options?.reply ? postsToProvider : deliverToProvider) && !quiet && !await isConversationDeliveryPaused(context.conversationId)) {
6944
7011
  if (!conversationLocation || !deliverMessage) throw new Error(`Conversation ${context.conversationId} cannot deliver to its Location`);
6945
7012
  deliveryResult = await deliverMessage({
6946
7013
  cards,
@@ -7048,6 +7115,8 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
7048
7115
  const reply = finalized.reply;
7049
7116
  modelFailureEventId = finalized.eventId;
7050
7117
  if (reply.diagnostics.outcome !== "success") await deliverAssistantMessage(reply.text);
7118
+ else if (reply.reply) await deliverAssistantMessage(reply.reply.text, { reply: true });
7119
+ else if (reply.blocked) await blockRunAutomation(context.conversationId, reply.blocked);
7051
7120
  else if (reply.noReply?.note && isEventTurn) await deliverAssistantMessage(reply.noReply.note, { quiet: true });
7052
7121
  const completedState = buildDeliveredTurnStatePatch({
7053
7122
  conversation,
@@ -7746,41 +7815,28 @@ function createArchiveAgentTool(conversationId) {
7746
7815
  }
7747
7816
  });
7748
7817
  }
7749
- // src/chat/tools/runtime/finish-automation-run.ts
7750
- const RESULT_GUIDANCE = ["Use `no_action` when the run worked and nothing should be posted, such as when a condition in the instruction is not met, or when a temporary failure stopped the work.", "Use `misconfigured` when the run cannot do its job until its creator changes the automation: a provider, tool, account, or access that the job needs is missing, a target no longer exists, or the instruction cannot be done. Do not use it for a temporary failure or a condition that is not met."].join(" ");
7751
- /** Create the tool that ends one Automation run with a declared result. */
7752
- function createFinishAutomationRunTool(options) {
7753
- const results = options.sendsMessage ? [
7754
- "send_message",
7755
- "no_action",
7756
- "misconfigured"
7757
- ] : ["no_action", "misconfigured"];
7818
+ // src/chat/tools/runtime/reply.ts
7819
+ /**
7820
+ * Create the tool that sets the reply of one gated Turn. The runtime posts the
7821
+ * reply after the Turn ends.
7822
+ */
7823
+ function createReplyTool() {
7758
7824
  return zodTool({
7759
7825
  annotations: {
7760
7826
  destructiveHint: false,
7761
- idempotentHint: true,
7762
- openWorldHint: false,
7827
+ idempotentHint: false,
7828
+ openWorldHint: true,
7763
7829
  readOnlyHint: false
7764
7830
  },
7765
- description: options.sendsMessage ? `End this automation run. Use \`send_message\` with the finished reminder, digest, alert, or answer; the runtime posts it to the stored destinations. This is the only way that the run posts, so a missing Slack posting tool does not make the run \`misconfigured\`. ${RESULT_GUIDANCE}` : `End this automation run. This automation posts nothing. ${RESULT_GUIDANCE}`,
7831
+ description: "Post the reply of this Turn when the Turn ends. When the run starts, the reply goes to its stored destinations. After the run posts, a reply goes to the run's Slack thread.",
7766
7832
  exposure: "modelOnly",
7767
- inputSchema: z.object({
7768
- result: z.enum(results),
7769
- ...options.sendsMessage ? { message: z.string().optional().describe("Required for send_message. The text to post.") } : void 0,
7770
- reason: z.string().optional().describe("Required for no_action and misconfigured. One sentence for the creator.")
7771
- }),
7772
- outputSchema: juniorToolOutputSchema.extend({ result: z.enum([
7773
- "send_message",
7774
- "no_action",
7775
- "misconfigured"
7776
- ]) }),
7833
+ inputSchema: z.object({ text: z.string().describe("The finished message, such as a reminder, digest, or alert.") }).strict(),
7834
+ outputSchema: juniorToolOutputSchema.extend({ text: z.string() }),
7777
7835
  execute: async (input) => {
7778
- const parsed = automationResultSchema$1.safeParse(input);
7779
- if (!parsed.success) throw new ToolInputError(input.result === "send_message" ? "send_message requires a non-empty message." : `${input.result} requires a non-empty reason.`);
7780
- return parsed.data.result === "send_message" && isLegacyNoReplyMarker(parsed.data.message) ? {
7781
- result: "no_action",
7782
- reason: "The message was the no-reply marker."
7783
- } : parsed.data;
7836
+ if (isLegacyNoReplyMarker(input.text)) throw new ToolInputError(`To post nothing, call \`${NO_REPLY_TOOL_NAME}\` instead.`);
7837
+ const text = replyTextSchema.safeParse(input.text);
7838
+ if (!text.success) throw new ToolInputError("The reply text must not be empty.");
7839
+ return { text: text.data };
7784
7840
  }
7785
7841
  });
7786
7842
  }
@@ -7802,8 +7858,22 @@ function createNoReplyTool() {
7802
7858
  });
7803
7859
  }
7804
7860
  // src/chat/tools/runtime/report-blocked.ts
7805
- /** Create the tool that ends a child agent run as blocked. */
7806
- function createReportBlockedTool() {
7861
+ const DESCRIPTIONS = {
7862
+ parent: {
7863
+ tool: "End this delegated task as blocked. Call this when missing access, credentials, input, or a decision stops the task, also when a search for the missing part found nothing. Do not guess, mock, or fake results to work around it.",
7864
+ missing: "What the task needs and who can give it. Add the work you already did, so the parent does not repeat it."
7865
+ },
7866
+ automation: {
7867
+ tool: "End this Turn and block the Automation until someone fixes it. Call this when a provider, tool, account, or access that the job needs is missing, a target no longer exists, or the instruction cannot be done. Do not call it for a temporary failure or a condition that is not met.",
7868
+ missing: "What the Automation needs and who can give it. One sentence for the creator."
7869
+ }
7870
+ };
7871
+ /**
7872
+ * Create the tool that ends a Turn as blocked. `parent`: a child agent reports
7873
+ * to its parent. `automation`: the Automation is blocked.
7874
+ */
7875
+ function createReportBlockedTool(target) {
7876
+ const descriptions = DESCRIPTIONS[target];
7807
7877
  return zodTool({
7808
7878
  annotations: {
7809
7879
  destructiveHint: false,
@@ -7811,9 +7881,9 @@ function createReportBlockedTool() {
7811
7881
  openWorldHint: false,
7812
7882
  readOnlyHint: false
7813
7883
  },
7814
- description: "End this delegated task as blocked. Call this when missing access, credentials, input, or a decision stops the task, also when a search for the missing part found nothing. Do not guess, mock, or fake results to work around it.",
7884
+ description: descriptions.tool,
7815
7885
  exposure: "modelOnly",
7816
- inputSchema: z.object({ missing: z.string().trim().min(1).describe("What the task needs and who can give it. Add the work you already did, so the parent does not repeat it.") }).strict(),
7886
+ inputSchema: z.object({ missing: z.string().trim().min(1).describe(descriptions.missing) }).strict(),
7817
7887
  outputSchema: juniorToolOutputSchema.extend({ missing: z.string() }),
7818
7888
  execute: async (input) => ({ missing: input.missing })
7819
7889
  });
@@ -8657,7 +8727,7 @@ function subjectInput(subject) {
8657
8727
  /** Create the tool that adds a Review item or updates the open one. */
8658
8728
  function createAddReviewItemTool(context, services) {
8659
8729
  return zodTool({
8660
- description: `Ask a person for input, or tell them about work that needs them. This is how you ask a person anything: the item goes on the review desk, and in a Slack thread it also shows as a card with buttons. Write the question so it stands alone: a person who sees only the card must understand it. Put the option that you recommend first, set \`recommended: true\` on it, and say why in its description. Use kind \`action\` with a \`request\` to ask: a question and 1-4 fields. Each field is \`choice\` (pick one), \`multi_choice\` (pick any), or \`text\` (a short answer). For a simple decision, use one \`choice\` field. Ask for related input in one item. Use kind \`notice\` only to tell a person something. Assignees default to the person in this Turn, to the Automation creator in an Automation run, or else to the people still subscribed to the Conversation. The current Conversation is always linked. The answer arrives later as a \`<review-item-answer>\` with the item id, or a \`<review-item-dismissed>\` when the person dismisses it. A reply that the assignee types in the thread also closes the item when the reply answers it. If your next step needs the answer, end the Turn now: the card is your reply, so do not write text: call \`${NO_REPLY_TOOL_NAME}\`, or finish the Automation run. If other work does not need the answer, continue with it. If an open item has the same \`dedupe_key\`, this updates that item instead of adding another.`,
8730
+ description: `Ask a person for input, or tell them about work that needs them. This is how you ask a person anything: the item goes on the review desk, and in a Slack thread it also shows as a card with buttons. Write the question so it stands alone: a person who sees only the card must understand it. Put the option that you recommend first, set \`recommended: true\` on it, and say why in its description. Use kind \`action\` with a \`request\` to ask: a question and 1-4 fields. Each field is \`choice\` (pick one), \`multi_choice\` (pick any), or \`text\` (a short answer). For a simple decision, use one \`choice\` field. Ask for related input in one item. Use kind \`notice\` only to tell a person something. Assignees default to the person in this Turn, to the Automation creator in an Automation run, or else to the people still subscribed to the Conversation. The current Conversation is always linked. The answer arrives later as a \`<review-item-answer>\` with the item id, or a \`<review-item-dismissed>\` when the person dismisses it. A reply that the assignee types in the thread also closes the item when the reply answers it. If your next step needs the answer, end the Turn now: the card is your reply, so do not write text: call \`${NO_REPLY_TOOL_NAME}\`. If other work does not need the answer, continue with it. If an open item has the same \`dedupe_key\`, this updates that item instead of adding another.`,
8661
8731
  annotations: {
8662
8732
  destructiveHint: false,
8663
8733
  idempotentHint: true,
@@ -9598,9 +9668,10 @@ function refersTo(text, person) {
9598
9668
  * "the Automation creator" as its creator, so the text calls the creator
9599
9669
  * that. Every other requester needs their Slack mention, because a display
9600
9670
  * name does not notify the person and it can match another person. A run
9601
- * ends with a declared result, so a legacy no-reply marker does nothing. A
9602
- * problem that the previous text already had stays allowed, so an edit does
9603
- * not have to rewrite text that the requester did not change.
9671
+ * ends with `reply`, `noReply`, or `reportBlocked`, so a legacy no-reply
9672
+ * marker does nothing. A problem that the previous text already had stays
9673
+ * allowed, so an edit does not have to rewrite text that the requester did
9674
+ * not change.
9604
9675
  */
9605
9676
  function taskTextProblem(text, references) {
9606
9677
  const { creator, requester, previousText, label } = references;
@@ -16659,8 +16730,8 @@ function createTools(availableSkills, hooks = {}, context, options = {}) {
16659
16730
  parentConversationId: context.parentConversationId
16660
16731
  });
16661
16732
  if (context.messageAgent) tools.messageAgent = createMessageAgentTool(context.messageAgent);
16662
- if (turnTools.reportBlocked) tools[REPORT_BLOCKED_TOOL_NAME] = createReportBlockedTool();
16663
- if (context.automation) tools[FINISH_AUTOMATION_RUN_TOOL_NAME] = createFinishAutomationRunTool(context.automation);
16733
+ if (turnTools.reply) tools[REPLY_TOOL_NAME] = createReplyTool();
16734
+ if (turnTools.reportBlocked !== "none") tools[REPORT_BLOCKED_TOOL_NAME] = createReportBlockedTool(turnTools.reportBlocked);
16664
16735
  if (turnTools.noReply) tools[NO_REPLY_TOOL_NAME] = createNoReplyTool();
16665
16736
  if (context.mcpToolManager) {
16666
16737
  tools.searchMcpTools = createSearchMcpToolsTool(context.mcpToolManager);
@@ -20080,7 +20151,10 @@ async function wireAgentTools(args) {
20080
20151
  const commonToolRuntimeContext = {
20081
20152
  conversationId: args.run.conversationId,
20082
20153
  turnId: args.run.turnId,
20083
- turnTools: args.behavior.tools,
20154
+ turnTools: {
20155
+ ...args.behavior.tools,
20156
+ reply: args.behavior.tools.reply && args.run.dispatch?.outcomes?.length !== 0
20157
+ },
20084
20158
  ...args.run.parentConversationId ? { parentConversationId: args.run.parentConversationId } : void 0,
20085
20159
  ...args.run.location ? {
20086
20160
  location: args.run.location,
@@ -20108,8 +20182,7 @@ async function wireAgentTools(args) {
20108
20182
  supportsImageInput: args.supportsImageInput,
20109
20183
  surface: args.surface,
20110
20184
  ...args.currentActor ? { resolveActorIdentity: async () => await readActorIdentity(args.currentActor) } : void 0,
20111
- ...bindAgentTools(args.run, args.behavior.tools.agents),
20112
- ...args.behavior.tools.finishAutomationRun ? { automation: { sendsMessage: args.run.dispatch?.outcomes?.length !== 0 } } : void 0
20185
+ ...bindAgentTools(args.run, args.behavior.tools.agents)
20113
20186
  };
20114
20187
  const toolRoute = resolveToolRuntimeRoute({
20115
20188
  actor: args.currentActor,
@@ -20774,11 +20847,6 @@ async function requestAboveMark(args) {
20774
20847
  }
20775
20848
  }], { activity: "preserve" })).length === 0) return;
20776
20849
  await args.queue.send(message);
20777
- logInfo("context_compaction.background.requested", {
20778
- "app.compaction.mark_seq": markSeq,
20779
- "app.compaction.history_version": historyVersion,
20780
- "app.compaction.input.size": args.inputSize
20781
- });
20782
20850
  }
20783
20851
  /** A fixed label for a failed summary. Never raw exception text. */
20784
20852
  function failureLabel(error, signal) {
@@ -21703,7 +21771,7 @@ async function applyPreparedSummary(args, prepared, budget) {
21703
21771
  */
21704
21772
  const EXCLUSIVE_TOOL_NAMES = [
21705
21773
  "switchWorkspace",
21706
- FINISH_AUTOMATION_RUN_TOOL_NAME,
21774
+ REPLY_TOOL_NAME,
21707
21775
  REPORT_BLOCKED_TOOL_NAME,
21708
21776
  NO_REPLY_TOOL_NAME
21709
21777
  ];
@@ -21733,7 +21801,10 @@ function recordToolBatch(stats, toolCalls, tools) {
21733
21801
  stats.sequentialCallCount += toolCalls.length;
21734
21802
  for (const name of sequentialTools) stats.sequentialToolNames.add(name);
21735
21803
  }
21736
- /** Span attributes for the batch counts of one Run. */
21804
+ /**
21805
+ * Span attributes for the batch counts of one Run, set on its
21806
+ * `gen_ai.invoke_agent` span because production drops info logs.
21807
+ */
21737
21808
  function toolBatchSpanAttributes(stats) {
21738
21809
  return {
21739
21810
  "app.tool_batch.count": stats.count,
@@ -21812,17 +21883,15 @@ async function executeAgentRun(run, streamFn) {
21812
21883
  runId: run.runId,
21813
21884
  assistantUserName: botConfig.userName
21814
21885
  };
21815
- return withLogContext(runLogContext, () => runWithConversationPrivacy(conversationPrivacy, () => executeAgentRunInPrivacyContext(run, conversation?.kind ?? "root", conversationPrivacy, runLogContext, streamFn)));
21886
+ return withLogContext(runLogContext, () => runWithConversationPrivacy(conversationPrivacy, () => executeAgentRunInPrivacyContext(run, run.dispatch?.declaresResult ? "automation" : conversation?.kind ?? "root", conversationPrivacy, runLogContext, streamFn)));
21816
21887
  }
21817
21888
  async function executeAgentRunInPrivacyContext(run, conversationKind, conversationPrivacy, runLogContext, streamFn) {
21818
21889
  const conversationId = run.conversationId;
21819
21890
  const turnId = run.turnId;
21820
21891
  const behavior = turnBehavior({
21821
21892
  kind: conversationKind,
21822
- personInput: isPersonInput(run.source.kind),
21823
- automationRun: run.dispatch?.declaresResult === true
21893
+ personInput: isPersonInput(run.source.kind)
21824
21894
  });
21825
- const requireAutomationResult = behavior.gated;
21826
21895
  const input = {
21827
21896
  actor: run.instruction.actor,
21828
21897
  messageText: run.instruction.text,
@@ -22165,19 +22234,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22165
22234
  promptName: CONTEXT_COMPACTION_PROMPT_NAME,
22166
22235
  ...streamFn ? { base: streamFn } : void 0
22167
22236
  });
22168
- let replacementAwaitingInput;
22169
- /** Log the first provider-reported input after a replacement. */
22170
- const logFirstInputAfterReplacement = () => {
22171
- if (!replacementAwaitingInput) return;
22172
- const inputSize = lastRequestInputSize(agent.state.messages.slice(replacementAwaitingInput.messageCount));
22173
- if (!inputSize) return;
22174
- logInputAfterCompaction({
22175
- inputSize,
22176
- mode: replacementAwaitingInput.mode,
22177
- threshold: getAgentContextCompactionTriggerTokens(activeModelId)
22178
- });
22179
- replacementAwaitingInput = void 0;
22180
- };
22237
+ const nextInputAfterReplacement = createNextInputTracker();
22181
22238
  /** Commit and adopt an active capacity replacement before another model call. */
22182
22239
  const applyActiveContextCompaction = async (messages, hookSignal, pendingMessages, clearSteeringQueueOnCommit = false, pairPendingRuntimeContext = false, mode = "active") => {
22183
22240
  const compaction = await compactWithPreparedSummary({
@@ -22204,10 +22261,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22204
22261
  throw error;
22205
22262
  }
22206
22263
  agent.state.messages = replacement;
22207
- replacementAwaitingInput = {
22208
- messageCount: replacement.length,
22209
- mode
22210
- };
22264
+ nextInputAfterReplacement.replaced(mode, getAgentContextCompactionTriggerTokens(activeModelId));
22211
22265
  runResume.setBeforeMessageCount(replacement.length);
22212
22266
  runResume.adoptCommittedBoundary(replacement);
22213
22267
  if (clearSteeringQueueOnCommit && pendingMessages?.length) agent.clearSteeringQueue();
@@ -22281,7 +22335,8 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22281
22335
  sessionId: conversationId,
22282
22336
  streamFn: createTracedStreamFn({
22283
22337
  conversationPrivacy,
22284
- base: cacheWarming.wrap(streamFn)
22338
+ base: cacheWarming.wrap(streamFn),
22339
+ endAttributes: (message) => nextInputAfterReplacement.attributes(lastRequestInputSize([message]))
22285
22340
  }),
22286
22341
  steeringMode: "all",
22287
22342
  beforeToolCall: async ({ assistantMessage, context, toolCall }) => {
@@ -22327,12 +22382,14 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22327
22382
  const sourceResult = timedOutResult ?? result;
22328
22383
  const projectedResult = wiring.projectActionReviewResult(toolCall.id, sourceResult);
22329
22384
  const override = timedOutResult || projectedResult !== result ? projectedResult : void 0;
22330
- if ((toolCall.name === "finishAutomationRun" || toolCall.name === "reportBlocked" || toolCall.name === "noReply") && !isError && !override) return { terminate: true };
22385
+ if ((toolCall.name === "reply" || toolCall.name === "reportBlocked" || toolCall.name === "noReply") && !isError && !override) {
22386
+ if (toolCall.name === "noReply" && !behavior.gated) cacheWarming.noReplyEnded();
22387
+ return { terminate: true };
22388
+ }
22331
22389
  return override;
22332
22390
  },
22333
22391
  prepareNextTurnWithContext: async (nextTurn, hookSignal) => {
22334
22392
  try {
22335
- logFirstInputAfterReplacement();
22336
22393
  if (hookSignal?.aborted) return;
22337
22394
  const stepUpdate = await withSpan("agent.step.prepare", "agent.step.prepare", {}, async () => {
22338
22395
  const contextUpdate = await repositoryInstructionsContext.applyUpdate(nextTurn.context);
@@ -22382,6 +22439,8 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22382
22439
  }
22383
22440
  });
22384
22441
  let newMessages = [];
22442
+ const turnStartIndex = () => existingSessionRecord?.turnStartMessageIndex ?? runResume.turnStartMessageIndex ?? runResume.beforeMessageCount;
22443
+ const turnMessages = () => agent.state.messages.slice(turnStartIndex());
22385
22444
  try {
22386
22445
  if (resumedFromSessionRecord) {
22387
22446
  agent.state.messages = shouldPromptAgent ? promptHistoryMessages : existingSessionRecord.piMessages;
@@ -22392,7 +22451,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22392
22451
  if (shouldPromptAgent) runResume.setTurnStartMessageIndex(agent.state.messages.length);
22393
22452
  const authPauseOutcome = await withSpan(`invoke_agent ${botConfig.userName}`, "gen_ai.invoke_agent", spanContext, async (setInvokeAgentSpanAttributes) => {
22394
22453
  setAgentSpanAttributes = setInvokeAgentSpanAttributes;
22395
- if (requireAutomationResult && readAutomationResult(agent.state.messages)) return;
22454
+ if (behavior.gated && readTurnAnswer(turnMessages())) return;
22396
22455
  const promptTimestamp = restoredPromptTimestamp ?? Date.now();
22397
22456
  const contextMessage = shouldPromptAgent && promptContextContentParts.length > 0 ? {
22398
22457
  role: "user",
@@ -22497,7 +22556,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22497
22556
  run = shouldPromptAgent && !capacityUpdate ? agent.prompt(freshPromptMessage) : agent.continue();
22498
22557
  discardedRetryUsage = void 0;
22499
22558
  let actionConfirmationRetryUsed = false;
22500
- let automationResultReminderUsed = !requireAutomationResult;
22559
+ let answerReminderUsed = !behavior.gated;
22501
22560
  let providerRetryAttempt = 0;
22502
22561
  let refusalFallbackUsed = false;
22503
22562
  let emptyOutputAttempt = 0;
@@ -22538,12 +22597,12 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22538
22597
  run = agent.continue();
22539
22598
  continue;
22540
22599
  }
22541
- const automationResultReminder = automationResultReminderUsed ? void 0 : remindMissingAutomationResult(agent.state.messages);
22542
- if (automationResultReminder) {
22543
- automationResultReminderUsed = true;
22544
- agent.state.messages = automationResultReminder;
22545
- await runResume.persistSafeBoundary(automationResultReminder);
22546
- logWarn("agent.turn.automation_result.reminded", {});
22600
+ const answerReminder = answerReminderUsed ? void 0 : remindMissingAnswer(agent.state.messages, turnStartIndex());
22601
+ if (answerReminder) {
22602
+ answerReminderUsed = true;
22603
+ agent.state.messages = answerReminder;
22604
+ await runResume.persistSafeBoundary(answerReminder);
22605
+ logWarn("agent.turn.answer.reminded", {});
22547
22606
  run = agent.continue();
22548
22607
  continue;
22549
22608
  }
@@ -22630,7 +22689,10 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22630
22689
  reasoningLevel,
22631
22690
  assistantUserName: botConfig.userName,
22632
22691
  modelId: activeModelId,
22633
- requireAutomationResult
22692
+ ...behavior.gated ? {
22693
+ answer: readTurnAnswer(turnMessages()) ?? "missing",
22694
+ missingAnswerFails: Boolean(run.dispatch)
22695
+ } : void 0
22634
22696
  })
22635
22697
  };
22636
22698
  } catch (error) {