@namzu/sdk 64.4.0 → 65.0.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 (36) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/agents/explore.js +1 -1
  3. package/dist/agents/explore.js.map +1 -1
  4. package/dist/agents/plan.js +1 -1
  5. package/dist/agents/plan.js.map +1 -1
  6. package/dist/prompt/coding-agent-doctrine.d.ts +2 -2
  7. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  8. package/dist/prompt/coding-agent-doctrine.js +39 -44
  9. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  10. package/dist/provider/fallback.d.ts.map +1 -1
  11. package/dist/provider/fallback.js +4 -3
  12. package/dist/provider/fallback.js.map +1 -1
  13. package/dist/provider/idle-timeout.js +1 -1
  14. package/dist/provider/idle-timeout.js.map +1 -1
  15. package/dist/provider/retry.js +1 -1
  16. package/dist/provider/retry.js.map +1 -1
  17. package/dist/runtime/query/iteration/index.d.ts +9 -0
  18. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  19. package/dist/runtime/query/iteration/index.js +49 -8
  20. package/dist/runtime/query/iteration/index.js.map +1 -1
  21. package/dist/runtime/query/turn/stall-monitor.d.ts +21 -0
  22. package/dist/runtime/query/turn/stall-monitor.d.ts.map +1 -1
  23. package/dist/runtime/query/turn/stall-monitor.js +40 -4
  24. package/dist/runtime/query/turn/stall-monitor.js.map +1 -1
  25. package/dist/types/provider/interface.d.ts +8 -6
  26. package/dist/types/provider/interface.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/src/agents/explore.ts +1 -1
  29. package/src/agents/plan.ts +1 -1
  30. package/src/prompt/coding-agent-doctrine.ts +40 -45
  31. package/src/provider/fallback.ts +4 -3
  32. package/src/provider/idle-timeout.ts +1 -1
  33. package/src/provider/retry.ts +1 -1
  34. package/src/runtime/query/iteration/index.ts +56 -11
  35. package/src/runtime/query/turn/stall-monitor.ts +48 -4
  36. package/src/types/provider/interface.ts +8 -6
@@ -37,7 +37,7 @@ import { withoutVoidAssistantTurns } from '../request-void-turns.js';
37
37
  import { formatSteeringNote, isOperatorUserMessage } from '../steering.js';
38
38
  import { CompletionAudit } from '../turn/completion-audit.js';
39
39
  import { OutcomeLedger } from '../turn/outcome-ledger.js';
40
- import { FORCED_STEP_MESSAGE, REASONING_CAPPED_MESSAGE, REASONING_ONLY_MESSAGE, StallMonitor, asksQuestion, callChangedState, reasoningCapChars, } from '../turn/stall-monitor.js';
40
+ import { FORCED_STEP_MESSAGE, REASONING_CAPPED_MESSAGE, REASONING_ONLY_MESSAGE, StallMonitor, asksQuestion, callChangedState, callMadeProgress, isSetAsideTool, reasoningCapChars, } from '../turn/stall-monitor.js';
41
41
  import { effortForModel } from './effort-clamp.js';
42
42
  import { parseNativeCandidate } from './native-output.js';
43
43
  import { drainArrivedTaskCompletions, holdForOutstandingWork, settleOutstandingWork, } from './outstanding-work.js';
@@ -758,6 +758,7 @@ export class IterationOrchestrator {
758
758
  .toLLMTools(stepAllowedTools)
759
759
  .filter((tool) => this.ctx.structuredOutput?.mode !== 'native' ||
760
760
  tool.function.name !== STRUCTURED_OUTPUT_TOOL_NAME);
761
+ this.stepCannotChange = this.toolsCannotChange(llmTools);
761
762
  // The same list the request was built from now also bounds what
762
763
  // may run. Narrowing only the request left the restriction
763
764
  // presentational — the model was shown fewer tools and could
@@ -1008,11 +1009,23 @@ export class IterationOrchestrator {
1008
1009
  const stepEffort = forcedAction && requestEffort && (offeredEfforts?.includes('low') ?? false)
1009
1010
  ? 'low'
1010
1011
  : requestEffort;
1011
- // A provider that refuses a forced tool choice (some models do, and
1012
- // so does manual extended thinking) is not sent one: the step keeps
1013
- // its low effort and asks in words, on this request only.
1014
- const forcedChoiceRefused = forcedAction &&
1015
- this.ctx.provider.acceptsForcedToolChoiceFor?.(stepModel, turnConfig.thinking, stepEffort) === false;
1012
+ // A guard's action step sends a forced tool choice only where the
1013
+ // provider says one is safe and thinking is off for the request.
1014
+ // Every other case (a refusal, no answer, thinking on) asks in
1015
+ // words, on this request only, and keeps the step's low effort.
1016
+ //
1017
+ // A choice the step itself set (`step.toolChoice`) is a forced choice
1018
+ // whoever set it: `required` or a named function is dropped, and asked
1019
+ // in words, when the provider says it would refuse it.
1020
+ const stepChoiceForced = step.toolChoice !== undefined &&
1021
+ step.toolChoice !== 'auto' &&
1022
+ step.toolChoice !== 'none';
1023
+ const thinkingOn = turnConfig.thinking !== undefined && turnConfig.thinking.type !== 'disabled';
1024
+ const forcedChoiceAnswer = forcedAction || stepChoiceForced
1025
+ ? this.ctx.provider.acceptsForcedToolChoiceFor?.(stepModel, turnConfig.thinking, stepEffort)
1026
+ : undefined;
1027
+ const forcedChoiceRefused = (forcedAction && (forcedChoiceAnswer !== true || thinkingOn)) ||
1028
+ (!forcedAction && stepChoiceForced && forcedChoiceAnswer === false);
1016
1029
  const operatorInputAtDispatch = this.latestUserMessage;
1017
1030
  const latestReviewUserMessage = (this.ctx.reviewAnswer || this.ctx.structuredOutput?.review) && operatorInputAtDispatch
1018
1031
  ? structuredClone(operatorInputAtDispatch)
@@ -1047,7 +1060,9 @@ export class IterationOrchestrator {
1047
1060
  : llmTools.length > 0
1048
1061
  ? forcedAction && !forcedChoiceRefused
1049
1062
  ? (step.toolChoice ?? 'required')
1050
- : step.toolChoice
1063
+ : stepChoiceForced && forcedChoiceRefused
1064
+ ? undefined
1065
+ : step.toolChoice
1051
1066
  : undefined,
1052
1067
  temperature: step.temperature ?? turnConfig.temperature,
1053
1068
  maxTokens: outputCapOverride ?? step.maxResponseTokens ?? turnConfig.maxResponseTokens,
@@ -3075,6 +3090,7 @@ export class IterationOrchestrator {
3075
3090
  const calls = new Map((response.message.toolCalls ?? []).map((c) => [c.id, c]));
3076
3091
  let changedState = false;
3077
3092
  const question = asksQuestion(this.latestUserMessage?.content);
3093
+ const cannotChange = this.stepCannotChange;
3078
3094
  for (const result of results) {
3079
3095
  const call = calls.get(result.toolCallId);
3080
3096
  let readOnly;
@@ -3085,7 +3101,7 @@ export class IterationOrchestrator {
3085
3101
  catch {
3086
3102
  readOnly = undefined;
3087
3103
  }
3088
- if (callChangedState(result.toolName, readOnly, result.isError)) {
3104
+ if (callMadeProgress(result.toolName, readOnly, result.isError, cannotChange)) {
3089
3105
  // The same tool with the same input and the same result as an
3090
3106
  // earlier call this turn changed nothing, whatever the tool is,
3091
3107
  // except a file edit: applying, reverting and applying again is
@@ -3101,6 +3117,7 @@ export class IterationOrchestrator {
3101
3117
  reasoningChars,
3102
3118
  changedState,
3103
3119
  question,
3120
+ cannotChange,
3104
3121
  });
3105
3122
  if (directive.kind === 'nudge') {
3106
3123
  this.ctx.log.info('Many steps without a change — nudging the model to act', {
@@ -3115,6 +3132,30 @@ export class IterationOrchestrator {
3115
3132
  this.forceActionNextStep = true;
3116
3133
  }
3117
3134
  }
3135
+ /** Whether every tool offered to the step in flight only reads. */
3136
+ stepCannotChange = false;
3137
+ /**
3138
+ * Whether an agent given these tools can change nothing: each one declares
3139
+ * itself read-only without being shown an input (the test the read-only
3140
+ * sub-agents' roster uses), task-list tools and `send_message` aside. A tool that does not say,
3141
+ * or that says so only for some inputs, counts as one that can change things.
3142
+ */
3143
+ toolsCannotChange(llmTools) {
3144
+ let looked = false;
3145
+ for (const { function: fn } of llmTools) {
3146
+ if (isSetAsideTool(fn.name))
3147
+ continue;
3148
+ try {
3149
+ if (this.ctx.tools.get(fn.name)?.isReadOnly?.(undefined) !== true)
3150
+ return false;
3151
+ }
3152
+ catch {
3153
+ return false;
3154
+ }
3155
+ looked = true;
3156
+ }
3157
+ return looked;
3158
+ }
3118
3159
  /** Fingerprints of the calls this turn has finished, for {@link seenAgain}. */
3119
3160
  finishedCalls = new Set();
3120
3161
  /**