@sema-agent/core 1.301.0 → 1.302.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.
@@ -23,7 +23,7 @@ import { toImageContent } from "./image.js";
23
23
  import { OUTPUT_TOOL_NAME, SKILLS_LISTING_PROBE_HEADER, resolveOutputRetries } from "./synthetic-tools.js";
24
24
  import { cacheFamilyOf, usageCostMicroUsd } from "./usage-accounting.js";
25
25
  import { assembleResult, errorCodeOf } from "./assemble-result.js";
26
- import { ATTACHMENT_BYTE_CAP, CHANGED_FILES_MAX, SKILLS_LISTING_DELTA_HEADER, advanceCadenceClock, agentListingDeltaHeader, agentListingInitialHeader, collectDateChange, collectDueAttachments, commitAgentListing, commitSkillsListing, createAttachmentState, rebaseCadenceWindows, reduceToolEnd, renderAgentListingDelta, renderMcpInstructionsDelta, renderOrphanedBackgroundTasks, renderSkillsListingDelta, renderToolsDelta, stampWriteAnchor } from "./turn-attachments.js";
26
+ import { ATTACHMENT_BYTE_CAP, CHANGED_FILES_MAX, SKILLS_LISTING_DELTA_HEADER, advanceCadenceClock, agentListingDeltaHeader, agentListingInitialHeader, collectDateChange, collectDueAttachments, collectInstructionsChange, commitAgentListing, commitInstructionsChange, commitSkillsListing, createAttachmentState, rebaseCadenceWindows, reduceToolEnd, renderAgentListingDelta, renderMcpInstructionsDelta, renderOrphanedBackgroundTasks, renderSkillsListingDelta, renderToolsDelta, stampWriteAnchor } from "./turn-attachments.js";
27
27
  import { prepareTask } from "./prepare-task.js";
28
28
  import { hasVerifiableStructureSignal } from "./grounding-signal.js";
29
29
  import { hasDestroy, isIsolated } from "../remote-env.js";
@@ -823,6 +823,10 @@ export class Runner {
823
823
  const listingsLive = (agentListingOn && prepared.agentListing !== undefined) || (skillsListingOn && prepared.skillsListing !== undefined);
824
824
  const attachState = attachmentsCfg !== undefined || listingsLive ? createAttachmentState() : undefined;
825
825
  const dateState = prepared.dateChange !== undefined ? { announcedDate: prepared.dateChange.legDate } : undefined;
826
+ const instrProbe = this.deps.probeInstructionSources;
827
+ const instrState = instrProbe !== undefined && prepared.instructionSources !== undefined && prepared.instructionSources.length > 0
828
+ ? { lastAnnouncedHash: new Map(prepared.instructionSources.map((s) => [s.path, s.contentHash])) }
829
+ : undefined;
826
830
  let cadenceTurns = 0;
827
831
  let lastTurnHadToolCalls = false;
828
832
  if (attachState !== undefined && attachmentsCfg?.backgroundTasks === true) {
@@ -1827,7 +1831,7 @@ export class Runner {
1827
1831
  }
1828
1832
  let boundaryAttachmentBytes = 0;
1829
1833
  let attachmentsPayload;
1830
- if ((dateState !== undefined || attachState !== undefined) &&
1834
+ if ((dateState !== undefined || instrState !== undefined || attachState !== undefined) &&
1831
1835
  !boundarySteered &&
1832
1836
  !finalizeInjected &&
1833
1837
  finalVerifyInjections === 0 &&
@@ -1936,6 +1940,27 @@ export class Runner {
1936
1940
  dateState.announcedDate = today;
1937
1941
  }
1938
1942
  }
1943
+ if (instrState !== undefined && instrProbe !== undefined && lastTurnHadToolCalls) {
1944
+ let probed = null;
1945
+ try {
1946
+ const PROBE_CEILING_MS = 2_000;
1947
+ probed = await Promise.race([
1948
+ instrProbe(prepared.instructionSources),
1949
+ new Promise((resolve) => {
1950
+ const t = setTimeout(() => resolve(null), PROBE_CEILING_MS);
1951
+ t.unref?.();
1952
+ }),
1953
+ ]);
1954
+ }
1955
+ catch {
1956
+ probed = null;
1957
+ }
1958
+ const cand = collectInstructionsChange(instrState, probed);
1959
+ if (cand !== undefined) {
1960
+ due.splice(due.length > 0 && due[0].source === "date_change" ? 1 : 0, 0, cand.attachment);
1961
+ commitInstructionsChange(instrState, cand.announced);
1962
+ }
1963
+ }
1939
1964
  if (due.length > 0) {
1940
1965
  attachmentsPayload = due.map((a) => `<system-reminder>\n${sanitizeUntrustedText(a.body)}\n</system-reminder>`).join("\n");
1941
1966
  for (const a of due)