@agent-native/core 0.84.34 → 0.84.35
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/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +8 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/a2a/response-text.ts +10 -1
- package/corpus/core/src/agent/production-agent.ts +23 -20
- package/corpus/core/src/agent/run-manager.ts +46 -1
- package/corpus/core/src/agent/thread-data-builder.ts +15 -2
- package/corpus/core/src/client/code-agent-chat-adapter.ts +8 -1
- package/corpus/core/src/client/sse-event-processor.ts +21 -3
- package/corpus/core/src/code-agents/transcript-normalizer.ts +31 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +8 -2
- package/corpus/core/src/server/agent-teams.ts +24 -2
- package/corpus/templates/analytics/changelog/2026-07-01-smoother-chat-streaming.md +6 -0
- package/dist/a2a/response-text.d.ts +1 -0
- package/dist/a2a/response-text.d.ts.map +1 -1
- package/dist/a2a/response-text.js +8 -2
- package/dist/a2a/response-text.js.map +1 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +31 -27
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-manager.d.ts +12 -0
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +32 -1
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +15 -2
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/client/code-agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/code-agent-chat-adapter.js +5 -1
- package/dist/client/code-agent-chat-adapter.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +21 -3
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/code-agents/transcript-normalizer.d.ts.map +1 -1
- package/dist/code-agents/transcript-normalizer.js +24 -0
- package/dist/code-agents/transcript-normalizer.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +2 -3
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +17 -2
- package/dist/server/agent-teams.js.map +1 -1
- package/package.json +1 -1
|
@@ -1861,7 +1861,6 @@ export async function runAgentLoop(opts) {
|
|
|
1861
1861
|
// means no hard-block this turn.
|
|
1862
1862
|
}
|
|
1863
1863
|
}
|
|
1864
|
-
const bufferTextUntilFinalGuard = Boolean(opts.finalResponseGuard);
|
|
1865
1864
|
let finalGuardRetries = 0;
|
|
1866
1865
|
let iterations = 0;
|
|
1867
1866
|
// Set when an in-loop processor aborts via `abort()` / throws a `TripWire`.
|
|
@@ -1889,7 +1888,7 @@ export async function runAgentLoop(opts) {
|
|
|
1889
1888
|
iterations = 1;
|
|
1890
1889
|
}
|
|
1891
1890
|
let assistantContent;
|
|
1892
|
-
let
|
|
1891
|
+
let streamedAssistantText = "";
|
|
1893
1892
|
let terminalStopReason;
|
|
1894
1893
|
const toolCallErrors = new Map();
|
|
1895
1894
|
let contextMessages = messages;
|
|
@@ -1940,7 +1939,7 @@ export async function runAgentLoop(opts) {
|
|
|
1940
1939
|
}
|
|
1941
1940
|
for (let retry = 0;; retry++) {
|
|
1942
1941
|
assistantContent = undefined;
|
|
1943
|
-
|
|
1942
|
+
streamedAssistantText = "";
|
|
1944
1943
|
terminalStopReason = undefined;
|
|
1945
1944
|
toolCallErrors.clear();
|
|
1946
1945
|
try {
|
|
@@ -1994,12 +1993,8 @@ export async function runAgentLoop(opts) {
|
|
|
1994
1993
|
}
|
|
1995
1994
|
}
|
|
1996
1995
|
if (event.type === "text-delta") {
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
}
|
|
2000
|
-
else {
|
|
2001
|
-
send({ type: "text", text: event.text });
|
|
2002
|
-
}
|
|
1996
|
+
streamedAssistantText += event.text;
|
|
1997
|
+
send({ type: "text", text: event.text });
|
|
2003
1998
|
}
|
|
2004
1999
|
else if (event.type === "thinking-delta") {
|
|
2005
2000
|
thinkingBuffer += event.text;
|
|
@@ -2158,47 +2153,56 @@ export async function runAgentLoop(opts) {
|
|
|
2158
2153
|
throw err;
|
|
2159
2154
|
}
|
|
2160
2155
|
}
|
|
2161
|
-
const
|
|
2162
|
-
if (
|
|
2156
|
+
const flushUnstreamedAssistantText = () => {
|
|
2157
|
+
if (streamedAssistantText)
|
|
2163
2158
|
return;
|
|
2164
|
-
const text =
|
|
2159
|
+
const text = collectTextParts(assistantContentForHistory);
|
|
2165
2160
|
if (text)
|
|
2166
2161
|
send({ type: "text", text });
|
|
2167
2162
|
};
|
|
2168
2163
|
if (toolCallParts.length === 0) {
|
|
2169
2164
|
if (terminalStopReason === "max_tokens") {
|
|
2170
|
-
|
|
2165
|
+
flushUnstreamedAssistantText();
|
|
2171
2166
|
appendAgentLoopContinuation(messages, "max_tokens");
|
|
2172
2167
|
continue;
|
|
2173
2168
|
}
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2169
|
+
let guard = null;
|
|
2170
|
+
if (opts.finalResponseGuard) {
|
|
2171
|
+
try {
|
|
2172
|
+
guard = await opts.finalResponseGuard({
|
|
2173
|
+
messages,
|
|
2174
|
+
assistantContent: assistantContentForHistory,
|
|
2175
|
+
text: collectTextParts(assistantContentForHistory),
|
|
2176
|
+
toolCalls: [...toolCallHistory],
|
|
2177
|
+
toolResults: [...toolResultHistory],
|
|
2178
|
+
retryCount: finalGuardRetries,
|
|
2179
|
+
executionMode: opts.executionMode ?? "act",
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
catch (err) {
|
|
2183
|
+
send({ type: "clear" });
|
|
2184
|
+
throw err;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2185
2187
|
let guardEmittedFallback = false;
|
|
2186
2188
|
if (guard) {
|
|
2187
2189
|
const retryMessage = typeof guard === "string" ? guard : guard.retryMessage;
|
|
2188
2190
|
const fallbackMessage = typeof guard === "string" ? guard : guard.fallbackMessage;
|
|
2189
2191
|
if (finalGuardRetries < 1) {
|
|
2190
2192
|
finalGuardRetries += 1;
|
|
2193
|
+
send({ type: "clear" });
|
|
2191
2194
|
messages.push({
|
|
2192
2195
|
role: "user",
|
|
2193
2196
|
content: [{ type: "text", text: retryMessage }],
|
|
2194
2197
|
});
|
|
2195
2198
|
continue;
|
|
2196
2199
|
}
|
|
2200
|
+
send({ type: "clear" });
|
|
2197
2201
|
send({ type: "text", text: fallbackMessage ?? retryMessage });
|
|
2198
2202
|
guardEmittedFallback = true;
|
|
2199
2203
|
}
|
|
2200
2204
|
else {
|
|
2201
|
-
|
|
2205
|
+
flushUnstreamedAssistantText();
|
|
2202
2206
|
}
|
|
2203
2207
|
// Some providers (notably OpenAI Responses for gpt-5+) can stream a
|
|
2204
2208
|
// successful turn that contains only reasoning content and zero output
|
|
@@ -2208,7 +2212,7 @@ export async function runAgentLoop(opts) {
|
|
|
2208
2212
|
// Surface a plain-language error so the user knows what happened.
|
|
2209
2213
|
if (!guardEmittedFallback &&
|
|
2210
2214
|
collectTextParts(assistantContentForHistory).trim().length === 0 &&
|
|
2211
|
-
|
|
2215
|
+
streamedAssistantText.trim().length === 0) {
|
|
2212
2216
|
send({
|
|
2213
2217
|
type: "text",
|
|
2214
2218
|
text: "The model returned an empty response. This usually means reasoning used the full output-token budget. Try again, or pick a different model from the model menu.",
|
|
@@ -2222,7 +2226,7 @@ export async function runAgentLoop(opts) {
|
|
|
2222
2226
|
// finalGuardRetries stays at 1 from a prior cycle and the guard is
|
|
2223
2227
|
// permanently disabled for the rest of a long multi-step run.
|
|
2224
2228
|
finalGuardRetries = 0;
|
|
2225
|
-
|
|
2229
|
+
flushUnstreamedAssistantText();
|
|
2226
2230
|
let requestedActionStop = null;
|
|
2227
2231
|
// Human-in-the-loop approvals granted by the user for this turn (opt-in;
|
|
2228
2232
|
// empty for the overwhelming majority of turns). Keyed by the stable
|