@swirls/looms 0.11.0 → 0.11.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @swirls/looms
2
2
 
3
+ ## 0.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2ff6701: Wake idle agents on a non-interrupt steer. Queued steers still wait for open tool calls to finish, so in-flight work is not abandoned.
8
+
3
9
  ## 0.11.0
4
10
 
5
11
  ### Minor Changes
@@ -11,11 +17,11 @@
11
17
  ```ts
12
18
  const attributes = defineRunAttributes({
13
19
  tenantId: { required: true, index: true },
14
- })
20
+ });
15
21
 
16
- createLooms({ modules, attributes })
17
- postgresReplica({ url, additionalFields: attributes })
18
- loomsReplicaTables({ additionalFields: attributes })
22
+ createLooms({ modules, attributes });
23
+ postgresReplica({ url, additionalFields: attributes });
24
+ loomsReplicaTables({ additionalFields: attributes });
19
25
  ```
20
26
 
21
27
  - Each attribute is a text column named in snake_case unless `fieldName` is set. `index: true` adds an index. Each column and index is its own migration, and a new column is backfilled from the `attributes` JSON. `postgresEventLog` records these migrations in `looms_schema_migrations` and applies each one once.
@@ -23,248 +23,6 @@ export declare const callLlmEffect: NoInfer<import("@swirls/looms/core").LocalEf
23
23
  readonly alreadyCompacted?: boolean | undefined;
24
24
  readonly consumedSteerMessageIds?: readonly string[] | undefined;
25
25
  }, AgentDefinitionsTag | LlmTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
26
- readonly type: "agent.context.compacted";
27
- readonly payload: {
28
- readonly turn: number;
29
- readonly originalCount: number;
30
- readonly compactedCount: number;
31
- readonly summary?: string | undefined;
32
- readonly reason?: "manual" | "overflow" | "threshold" | undefined;
33
- readonly messages?: readonly {
34
- readonly role: "assistant" | "system" | "tool" | "user";
35
- readonly content: string;
36
- readonly toolCallId?: string | undefined;
37
- readonly name?: string | undefined;
38
- readonly toolCalls?: {
39
- readonly id: string;
40
- readonly name: string;
41
- readonly arguments: Schema.Json;
42
- }[] | undefined;
43
- }[] | undefined;
44
- };
45
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
46
- readonly type: "agent.effects.requested";
47
- readonly payload: {
48
- readonly toolCallId: string;
49
- readonly effects: readonly ({
50
- readonly type: "runtime.spawn";
51
- readonly childThreadId: string;
52
- readonly kind: string;
53
- readonly definitionName: string;
54
- readonly definitionVersion: string;
55
- readonly input: Schema.Json;
56
- } | {
57
- readonly type: "runtime.wait";
58
- readonly waitId: string;
59
- readonly on: {
60
- readonly type: string | readonly string[];
61
- readonly match?: Schema.Json | undefined;
62
- } | {
63
- readonly timerAt: number;
64
- };
65
- readonly tag?: Schema.Json | undefined;
66
- } | {
67
- readonly type: "runtime.emit";
68
- readonly event: {
69
- readonly type: string;
70
- readonly payload: Schema.Json;
71
- readonly threadId?: string | null | undefined;
72
- readonly parentThreadId?: string | null | undefined;
73
- readonly causationId?: string | null | undefined;
74
- readonly correlationId?: string | null | undefined;
75
- readonly effectId?: string | null | undefined;
76
- readonly origin?: {
77
- readonly type: "thread";
78
- readonly threadId: string;
79
- } | {
80
- readonly type: "external";
81
- readonly actorId?: string | undefined;
82
- } | {
83
- readonly type: "system";
84
- } | {
85
- readonly type: "run";
86
- readonly runId: string;
87
- } | undefined;
88
- readonly ephemeral?: boolean | undefined;
89
- readonly id?: string | undefined;
90
- readonly ts?: number | undefined;
91
- readonly idempotencyKey?: string | null | undefined;
92
- };
93
- readonly tag?: string | undefined;
94
- } | {
95
- readonly type: "runtime.complete";
96
- readonly output: Schema.Json;
97
- } | {
98
- readonly type: "runtime.fail";
99
- readonly error: string;
100
- } | {
101
- readonly type: "runtime.cancel";
102
- readonly threadId: string;
103
- readonly tag?: string | undefined;
104
- } | {
105
- readonly type: "runtime.launch";
106
- readonly runId: string;
107
- readonly kind: string;
108
- readonly definitionName: string;
109
- readonly definitionVersion: string;
110
- readonly input: Schema.Json;
111
- readonly close: "terminate" | "wait";
112
- readonly tag?: string | undefined;
113
- } | {
114
- readonly type: "runtime.cancelRun";
115
- readonly runId: string;
116
- readonly tag?: string | undefined;
117
- } | {
118
- readonly type: string;
119
- readonly input: Schema.Json;
120
- readonly tag?: string | undefined;
121
- readonly at?: number | undefined;
122
- })[];
123
- readonly waitOn?: {
124
- readonly type: string | readonly string[];
125
- readonly match?: Schema.Json | undefined;
126
- } | undefined;
127
- };
128
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
129
- readonly type: "agent.lineage";
130
- readonly payload: {
131
- readonly depth: number;
132
- };
133
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
134
- readonly type: "agent.message";
135
- readonly payload: {
136
- readonly turn: number;
137
- readonly message: {
138
- readonly role: "assistant" | "system" | "tool" | "user";
139
- readonly content: string;
140
- readonly toolCallId?: string | undefined;
141
- readonly name?: string | undefined;
142
- readonly toolCalls?: {
143
- readonly id: string;
144
- readonly name: string;
145
- readonly arguments: Schema.Json;
146
- }[] | undefined;
147
- };
148
- readonly usage?: {
149
- readonly input: number;
150
- readonly output: number;
151
- } | undefined;
152
- };
153
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
154
- readonly type: "agent.message.received";
155
- readonly payload: {
156
- readonly message: {
157
- readonly role: "assistant" | "system" | "tool" | "user";
158
- readonly content: string;
159
- readonly toolCallId?: string | undefined;
160
- readonly name?: string | undefined;
161
- readonly toolCalls?: {
162
- readonly id: string;
163
- readonly name: string;
164
- readonly arguments: Schema.Json;
165
- }[] | undefined;
166
- };
167
- };
168
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
169
- readonly type: "agent.session.cancel.requested";
170
- readonly payload: {};
171
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
172
- readonly type: "agent.session.message.submitted";
173
- readonly payload: {
174
- readonly messageId: string;
175
- readonly text: string;
176
- readonly delivery?: "followUp" | "nextTurn" | "steer" | undefined;
177
- readonly activeChildThreadId?: string | undefined;
178
- };
179
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
180
- readonly type: "agent.session.steer.delivered";
181
- readonly payload: {
182
- readonly messageId: string;
183
- readonly activeMessageId: string;
184
- };
185
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
186
- readonly type: "agent.session.turn.closed";
187
- readonly payload: {
188
- readonly messageId: string;
189
- readonly status: "cancelled" | "completed" | "failed";
190
- readonly error?: string | undefined;
191
- };
192
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
193
- readonly type: "agent.session.turn.started";
194
- readonly payload: {
195
- readonly messageId: string;
196
- readonly childThreadId: string;
197
- };
198
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
199
- readonly type: "agent.spawn.requested";
200
- readonly payload: {
201
- readonly childThreadId: string;
202
- readonly kind: string;
203
- readonly definitionName: string;
204
- readonly definitionVersion: string;
205
- readonly toolCallId: string;
206
- readonly input: Schema.Json;
207
- readonly depth?: number | undefined;
208
- };
209
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
210
- readonly type: "agent.steered";
211
- readonly payload: {
212
- readonly turn: number;
213
- readonly messageId?: string | undefined;
214
- readonly message: {
215
- readonly role: "assistant" | "system" | "tool" | "user";
216
- readonly content: string;
217
- readonly toolCallId?: string | undefined;
218
- readonly name?: string | undefined;
219
- readonly toolCalls?: {
220
- readonly id: string;
221
- readonly name: string;
222
- readonly arguments: Schema.Json;
223
- }[] | undefined;
224
- };
225
- readonly interrupt?: boolean | undefined;
226
- };
227
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
228
- readonly type: "agent.tool.result";
229
- readonly payload: {
230
- readonly turn: number;
231
- readonly toolCallId: string;
232
- readonly name: string;
233
- readonly result: Schema.Json;
234
- readonly error: string | null;
235
- };
236
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
237
- readonly type: "agent.tool_call.requested";
238
- readonly payload: {
239
- readonly turn: number;
240
- readonly toolCall: {
241
- readonly id: string;
242
- readonly name: string;
243
- readonly arguments: Schema.Json;
244
- };
245
- };
246
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
247
- readonly type: "agent.turn.started";
248
- readonly payload: {
249
- readonly turn: number;
250
- };
251
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
252
- readonly type: "agent.turn.stopped";
253
- readonly payload: {};
254
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
255
- readonly type: "agent.turn.text_delta";
256
- readonly payload: {
257
- readonly turn: number;
258
- readonly delta: string;
259
- };
260
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
261
- readonly type: "agent.turn.usage";
262
- readonly payload: {
263
- readonly turn: number;
264
- readonly input: number;
265
- readonly output: number;
266
- };
267
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
268
26
  readonly type: "runtime.child.close.requested";
269
27
  readonly payload: {
270
28
  readonly policy: "terminate" | "wait";
@@ -510,19 +268,7 @@ export declare const callLlmEffect: NoInfer<import("@swirls/looms/core").LocalEf
510
268
  readonly payload: Schema.Json;
511
269
  };
512
270
  };
513
- })>>;
514
- export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").LocalEffectDefinition<{
515
- readonly turn: number;
516
- readonly definitionName?: string | undefined;
517
- readonly definitionVersion: string;
518
- readonly toolCall: {
519
- readonly id: string;
520
- readonly name: string;
521
- readonly arguments: Schema.Json;
522
- };
523
- readonly input?: Schema.Json | undefined;
524
- readonly depth?: number | undefined;
525
- }, AgentDefinitionsTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
271
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
526
272
  readonly type: "agent.context.compacted";
527
273
  readonly payload: {
528
274
  readonly turn: number;
@@ -764,7 +510,19 @@ export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").Loc
764
510
  readonly input: number;
765
511
  readonly output: number;
766
512
  };
767
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
513
+ })>>;
514
+ export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").LocalEffectDefinition<{
515
+ readonly turn: number;
516
+ readonly definitionName?: string | undefined;
517
+ readonly definitionVersion: string;
518
+ readonly toolCall: {
519
+ readonly id: string;
520
+ readonly name: string;
521
+ readonly arguments: Schema.Json;
522
+ };
523
+ readonly input?: Schema.Json | undefined;
524
+ readonly depth?: number | undefined;
525
+ }, AgentDefinitionsTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
768
526
  readonly type: "runtime.child.close.requested";
769
527
  readonly payload: {
770
528
  readonly policy: "terminate" | "wait";
@@ -1010,5 +768,247 @@ export declare const executeToolEffect: NoInfer<import("@swirls/looms/core").Loc
1010
768
  readonly payload: Schema.Json;
1011
769
  };
1012
770
  };
771
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
772
+ readonly type: "agent.context.compacted";
773
+ readonly payload: {
774
+ readonly turn: number;
775
+ readonly originalCount: number;
776
+ readonly compactedCount: number;
777
+ readonly summary?: string | undefined;
778
+ readonly reason?: "manual" | "overflow" | "threshold" | undefined;
779
+ readonly messages?: readonly {
780
+ readonly role: "assistant" | "system" | "tool" | "user";
781
+ readonly content: string;
782
+ readonly toolCallId?: string | undefined;
783
+ readonly name?: string | undefined;
784
+ readonly toolCalls?: {
785
+ readonly id: string;
786
+ readonly name: string;
787
+ readonly arguments: Schema.Json;
788
+ }[] | undefined;
789
+ }[] | undefined;
790
+ };
791
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
792
+ readonly type: "agent.effects.requested";
793
+ readonly payload: {
794
+ readonly toolCallId: string;
795
+ readonly effects: readonly ({
796
+ readonly type: "runtime.spawn";
797
+ readonly childThreadId: string;
798
+ readonly kind: string;
799
+ readonly definitionName: string;
800
+ readonly definitionVersion: string;
801
+ readonly input: Schema.Json;
802
+ } | {
803
+ readonly type: "runtime.wait";
804
+ readonly waitId: string;
805
+ readonly on: {
806
+ readonly type: string | readonly string[];
807
+ readonly match?: Schema.Json | undefined;
808
+ } | {
809
+ readonly timerAt: number;
810
+ };
811
+ readonly tag?: Schema.Json | undefined;
812
+ } | {
813
+ readonly type: "runtime.emit";
814
+ readonly event: {
815
+ readonly type: string;
816
+ readonly payload: Schema.Json;
817
+ readonly threadId?: string | null | undefined;
818
+ readonly parentThreadId?: string | null | undefined;
819
+ readonly causationId?: string | null | undefined;
820
+ readonly correlationId?: string | null | undefined;
821
+ readonly effectId?: string | null | undefined;
822
+ readonly origin?: {
823
+ readonly type: "thread";
824
+ readonly threadId: string;
825
+ } | {
826
+ readonly type: "external";
827
+ readonly actorId?: string | undefined;
828
+ } | {
829
+ readonly type: "system";
830
+ } | {
831
+ readonly type: "run";
832
+ readonly runId: string;
833
+ } | undefined;
834
+ readonly ephemeral?: boolean | undefined;
835
+ readonly id?: string | undefined;
836
+ readonly ts?: number | undefined;
837
+ readonly idempotencyKey?: string | null | undefined;
838
+ };
839
+ readonly tag?: string | undefined;
840
+ } | {
841
+ readonly type: "runtime.complete";
842
+ readonly output: Schema.Json;
843
+ } | {
844
+ readonly type: "runtime.fail";
845
+ readonly error: string;
846
+ } | {
847
+ readonly type: "runtime.cancel";
848
+ readonly threadId: string;
849
+ readonly tag?: string | undefined;
850
+ } | {
851
+ readonly type: "runtime.launch";
852
+ readonly runId: string;
853
+ readonly kind: string;
854
+ readonly definitionName: string;
855
+ readonly definitionVersion: string;
856
+ readonly input: Schema.Json;
857
+ readonly close: "terminate" | "wait";
858
+ readonly tag?: string | undefined;
859
+ } | {
860
+ readonly type: "runtime.cancelRun";
861
+ readonly runId: string;
862
+ readonly tag?: string | undefined;
863
+ } | {
864
+ readonly type: string;
865
+ readonly input: Schema.Json;
866
+ readonly tag?: string | undefined;
867
+ readonly at?: number | undefined;
868
+ })[];
869
+ readonly waitOn?: {
870
+ readonly type: string | readonly string[];
871
+ readonly match?: Schema.Json | undefined;
872
+ } | undefined;
873
+ };
874
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
875
+ readonly type: "agent.lineage";
876
+ readonly payload: {
877
+ readonly depth: number;
878
+ };
879
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
880
+ readonly type: "agent.message";
881
+ readonly payload: {
882
+ readonly turn: number;
883
+ readonly message: {
884
+ readonly role: "assistant" | "system" | "tool" | "user";
885
+ readonly content: string;
886
+ readonly toolCallId?: string | undefined;
887
+ readonly name?: string | undefined;
888
+ readonly toolCalls?: {
889
+ readonly id: string;
890
+ readonly name: string;
891
+ readonly arguments: Schema.Json;
892
+ }[] | undefined;
893
+ };
894
+ readonly usage?: {
895
+ readonly input: number;
896
+ readonly output: number;
897
+ } | undefined;
898
+ };
899
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
900
+ readonly type: "agent.message.received";
901
+ readonly payload: {
902
+ readonly message: {
903
+ readonly role: "assistant" | "system" | "tool" | "user";
904
+ readonly content: string;
905
+ readonly toolCallId?: string | undefined;
906
+ readonly name?: string | undefined;
907
+ readonly toolCalls?: {
908
+ readonly id: string;
909
+ readonly name: string;
910
+ readonly arguments: Schema.Json;
911
+ }[] | undefined;
912
+ };
913
+ };
914
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
915
+ readonly type: "agent.session.cancel.requested";
916
+ readonly payload: {};
917
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
918
+ readonly type: "agent.session.message.submitted";
919
+ readonly payload: {
920
+ readonly messageId: string;
921
+ readonly text: string;
922
+ readonly delivery?: "followUp" | "nextTurn" | "steer" | undefined;
923
+ readonly activeChildThreadId?: string | undefined;
924
+ };
925
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
926
+ readonly type: "agent.session.steer.delivered";
927
+ readonly payload: {
928
+ readonly messageId: string;
929
+ readonly activeMessageId: string;
930
+ };
931
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
932
+ readonly type: "agent.session.turn.closed";
933
+ readonly payload: {
934
+ readonly messageId: string;
935
+ readonly status: "cancelled" | "completed" | "failed";
936
+ readonly error?: string | undefined;
937
+ };
938
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
939
+ readonly type: "agent.session.turn.started";
940
+ readonly payload: {
941
+ readonly messageId: string;
942
+ readonly childThreadId: string;
943
+ };
944
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
945
+ readonly type: "agent.spawn.requested";
946
+ readonly payload: {
947
+ readonly childThreadId: string;
948
+ readonly kind: string;
949
+ readonly definitionName: string;
950
+ readonly definitionVersion: string;
951
+ readonly toolCallId: string;
952
+ readonly input: Schema.Json;
953
+ readonly depth?: number | undefined;
954
+ };
955
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
956
+ readonly type: "agent.steered";
957
+ readonly payload: {
958
+ readonly turn: number;
959
+ readonly messageId?: string | undefined;
960
+ readonly message: {
961
+ readonly role: "assistant" | "system" | "tool" | "user";
962
+ readonly content: string;
963
+ readonly toolCallId?: string | undefined;
964
+ readonly name?: string | undefined;
965
+ readonly toolCalls?: {
966
+ readonly id: string;
967
+ readonly name: string;
968
+ readonly arguments: Schema.Json;
969
+ }[] | undefined;
970
+ };
971
+ readonly interrupt?: boolean | undefined;
972
+ };
973
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
974
+ readonly type: "agent.tool.result";
975
+ readonly payload: {
976
+ readonly turn: number;
977
+ readonly toolCallId: string;
978
+ readonly name: string;
979
+ readonly result: Schema.Json;
980
+ readonly error: string | null;
981
+ };
982
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
983
+ readonly type: "agent.tool_call.requested";
984
+ readonly payload: {
985
+ readonly turn: number;
986
+ readonly toolCall: {
987
+ readonly id: string;
988
+ readonly name: string;
989
+ readonly arguments: Schema.Json;
990
+ };
991
+ };
992
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
993
+ readonly type: "agent.turn.started";
994
+ readonly payload: {
995
+ readonly turn: number;
996
+ };
997
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
998
+ readonly type: "agent.turn.stopped";
999
+ readonly payload: {};
1000
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1001
+ readonly type: "agent.turn.text_delta";
1002
+ readonly payload: {
1003
+ readonly turn: number;
1004
+ readonly delta: string;
1005
+ };
1006
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
1007
+ readonly type: "agent.turn.usage";
1008
+ readonly payload: {
1009
+ readonly turn: number;
1010
+ readonly input: number;
1011
+ readonly output: number;
1012
+ };
1013
1013
  })>>;
1014
1014
  export declare function readToolCall(value: JsonValue): ToolCall | null;
@@ -24,8 +24,12 @@ export declare const userMessage: import("@swirls/looms/core").SignalDefinition<
24
24
  };
25
25
  }>;
26
26
  /**
27
- * Build the `agent.steered` event: inject a user message mid-run, optionally
28
- * interrupting the current turn so the agent replans immediately.
27
+ * Build the `agent.steered` event: inject a user message mid-run.
28
+ *
29
+ * With `interrupt: true` (the default), the current turn is abandoned and a new
30
+ * LLM call starts immediately. With `interrupt: false`, the message is queued
31
+ * for the next turn — and if the agent is already idle, that next turn starts
32
+ * now so the steer cannot sit forever.
29
33
  */
30
34
  export declare const steer: import("@swirls/looms/core").SignalDefinition<{
31
35
  readonly content: string;
@@ -21,11 +21,15 @@ export const userMessage = agentModule.signal({
21
21
  build: ({ content }) => agentModule.input('message.received', { message: { role: 'user', content } }),
22
22
  });
23
23
  /**
24
- * Build the `agent.steered` event: inject a user message mid-run, optionally
25
- * interrupting the current turn so the agent replans immediately.
24
+ * Build the `agent.steered` event: inject a user message mid-run.
25
+ *
26
+ * With `interrupt: true` (the default), the current turn is abandoned and a new
27
+ * LLM call starts immediately. With `interrupt: false`, the message is queued
28
+ * for the next turn — and if the agent is already idle, that next turn starts
29
+ * now so the steer cannot sit forever.
26
30
  */
27
31
  export const steer = agentModule.signal({
28
- description: 'Inject a user message mid-run, optionally interrupting the current turn.',
32
+ description: 'Inject a user message mid-run. Interrupt abandons the current turn; otherwise the message waits for the next turn (which starts immediately if the agent is idle).',
29
33
  input: SteerInputSchema,
30
34
  build: ({ content, interrupt }) => agentModule.input('steered', {
31
35
  turn: 0,
@@ -182,10 +182,13 @@ export const agentThread = agentModule.thread({
182
182
  consumedSteerMessageIds,
183
183
  };
184
184
  }
185
+ // Queue for the next turn. If the agent is idle (no open tool calls), that turn
186
+ // starts now — otherwise the message rides along when tools finish.
185
187
  return {
186
188
  ...state,
187
189
  lines: [...state.lines, message],
188
190
  pendingSteer: message,
191
+ needsLlmCall: state.pendingToolCalls.length === 0,
189
192
  consumedSteerMessageIds,
190
193
  };
191
194
  }