open-agents-ai 0.187.233 → 0.187.235
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/dist/index.js +122 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -270510,8 +270510,10 @@ TASK: ${task}` : task;
|
|
|
270510
270510
|
this._lastTodoReminderTurn = -1;
|
|
270511
270511
|
let pendingConstraintWarnings = [];
|
|
270512
270512
|
let consecutiveTextOnly = 0;
|
|
270513
|
+
let consecutiveThinkOnly = 0;
|
|
270513
270514
|
let loopInterventionCount = 0;
|
|
270514
270515
|
const MAX_CONSECUTIVE_TEXT_ONLY = 3;
|
|
270516
|
+
const MAX_CONSECUTIVE_THINK_ONLY = 6;
|
|
270515
270517
|
let narratedToolCallCount = 0;
|
|
270516
270518
|
let consecutiveEmptyResponses = 0;
|
|
270517
270519
|
let sameToolFailStreak = 0;
|
|
@@ -271006,6 +271008,7 @@ ${memoryLines.join("\n")}`
|
|
|
271006
271008
|
consecutiveEmptyResponses = 0;
|
|
271007
271009
|
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
271008
271010
|
consecutiveTextOnly = 0;
|
|
271011
|
+
consecutiveThinkOnly = 0;
|
|
271009
271012
|
messages2.push({
|
|
271010
271013
|
role: "assistant",
|
|
271011
271014
|
content: msg.content || null,
|
|
@@ -271639,7 +271642,13 @@ Call task_complete(summary="...") NOW with whatever you have.`
|
|
|
271639
271642
|
} else {
|
|
271640
271643
|
const content = msg.content || "";
|
|
271641
271644
|
messages2.push({ role: "assistant", content });
|
|
271642
|
-
|
|
271645
|
+
if (isThinkOnly) {
|
|
271646
|
+
consecutiveThinkOnly++;
|
|
271647
|
+
consecutiveTextOnly = 0;
|
|
271648
|
+
} else {
|
|
271649
|
+
consecutiveTextOnly++;
|
|
271650
|
+
consecutiveThinkOnly = 0;
|
|
271651
|
+
}
|
|
271643
271652
|
this.emit({
|
|
271644
271653
|
type: "model_response",
|
|
271645
271654
|
content: content.slice(0, 200),
|
|
@@ -271655,6 +271664,20 @@ Call task_complete(summary="...") NOW with whatever you have.`
|
|
|
271655
271664
|
summary = content;
|
|
271656
271665
|
break;
|
|
271657
271666
|
}
|
|
271667
|
+
if (isThinkOnly) {
|
|
271668
|
+
if (consecutiveThinkOnly >= MAX_CONSECUTIVE_THINK_ONLY) {
|
|
271669
|
+
this.emit({
|
|
271670
|
+
type: "status",
|
|
271671
|
+
content: `Model produced ${consecutiveThinkOnly} consecutive think-only responses — nudging toward visible output`,
|
|
271672
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
271673
|
+
});
|
|
271674
|
+
messages2.push({
|
|
271675
|
+
role: "user",
|
|
271676
|
+
content: "You have been reasoning internally for several turns without producing visible output or tool calls. Please take action now — call a tool or produce a visible response."
|
|
271677
|
+
});
|
|
271678
|
+
}
|
|
271679
|
+
continue;
|
|
271680
|
+
}
|
|
271658
271681
|
if (consecutiveTextOnly >= MAX_CONSECUTIVE_TEXT_ONLY) {
|
|
271659
271682
|
this.emit({
|
|
271660
271683
|
type: "status",
|
|
@@ -271739,6 +271762,7 @@ Call task_complete(summary="...") NOW with whatever you have.`
|
|
|
271739
271762
|
}
|
|
271740
271763
|
prevCycleToolCalls = toolCallCount;
|
|
271741
271764
|
consecutiveTextOnly = 0;
|
|
271765
|
+
consecutiveThinkOnly = 0;
|
|
271742
271766
|
this.emit({
|
|
271743
271767
|
type: "status",
|
|
271744
271768
|
content: `Re-engaging — cycle ${bruteForceCycle} (${totalTurns} turns, ${toolCallCount} tool calls so far)`,
|
|
@@ -271883,8 +271907,10 @@ Integrate this guidance into your current approach. Continue working on the task
|
|
|
271883
271907
|
if (!choice)
|
|
271884
271908
|
break;
|
|
271885
271909
|
const msg = choice.message;
|
|
271910
|
+
const isThinkOnlyBF = response._thinkOnly === true;
|
|
271886
271911
|
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
271887
271912
|
consecutiveTextOnly = 0;
|
|
271913
|
+
consecutiveThinkOnly = 0;
|
|
271888
271914
|
messages2.push({ role: "assistant", content: msg.content || null, tool_calls: msg.toolCalls.map((tc) => ({ id: tc.id, type: "function", function: { name: tc.name, arguments: JSON.stringify(tc.arguments) } })) });
|
|
271889
271915
|
for (const tc of msg.toolCalls) {
|
|
271890
271916
|
if (this.aborted)
|
|
@@ -271970,7 +271996,13 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
|
|
|
271970
271996
|
} else {
|
|
271971
271997
|
const content = msg.content || "";
|
|
271972
271998
|
messages2.push({ role: "assistant", content });
|
|
271973
|
-
|
|
271999
|
+
if (isThinkOnlyBF) {
|
|
272000
|
+
consecutiveThinkOnly++;
|
|
272001
|
+
consecutiveTextOnly = 0;
|
|
272002
|
+
} else {
|
|
272003
|
+
consecutiveTextOnly++;
|
|
272004
|
+
consecutiveThinkOnly = 0;
|
|
272005
|
+
}
|
|
271974
272006
|
this.emit({ type: "model_response", content: content.slice(0, 200), turn, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
271975
272007
|
if (/task.?complete|all tests pass/i.test(content)) {
|
|
271976
272008
|
completed = true;
|
|
@@ -271988,6 +272020,15 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
|
|
|
271988
272020
|
break;
|
|
271989
272021
|
}
|
|
271990
272022
|
}
|
|
272023
|
+
if (isThinkOnlyBF) {
|
|
272024
|
+
if (consecutiveThinkOnly >= MAX_CONSECUTIVE_THINK_ONLY) {
|
|
272025
|
+
messages2.push({
|
|
272026
|
+
role: "user",
|
|
272027
|
+
content: "You have been reasoning internally for several turns without producing visible output or tool calls. Please take action now — call a tool or produce a visible response."
|
|
272028
|
+
});
|
|
272029
|
+
}
|
|
272030
|
+
continue;
|
|
272031
|
+
}
|
|
271991
272032
|
if (consecutiveTextOnly >= MAX_CONSECUTIVE_TEXT_ONLY) {
|
|
271992
272033
|
this.emit({
|
|
271993
272034
|
type: "status",
|
|
@@ -323527,6 +323568,81 @@ async function handleV1Models(res, ollamaUrl) {
|
|
|
323527
323568
|
});
|
|
323528
323569
|
}
|
|
323529
323570
|
}
|
|
323571
|
+
async function fetchAggregatedOllamaTags() {
|
|
323572
|
+
const out = [];
|
|
323573
|
+
modelRouteMap.clear();
|
|
323574
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
323575
|
+
const fetches = endpointRegistry.map(async (ep) => {
|
|
323576
|
+
try {
|
|
323577
|
+
const isOllama = ep.type === "ollama";
|
|
323578
|
+
const path5 = isOllama ? "/api/tags" : "/v1/models";
|
|
323579
|
+
const result = await ollamaRequest(ep.url, path5, "GET");
|
|
323580
|
+
if (result.status !== 200) return;
|
|
323581
|
+
const body = JSON.parse(result.body);
|
|
323582
|
+
if (isOllama) {
|
|
323583
|
+
const models = Array.isArray(body.models) ? body.models : [];
|
|
323584
|
+
for (const m2 of models) {
|
|
323585
|
+
const originalId = String(m2.name ?? m2.model ?? "");
|
|
323586
|
+
if (!originalId) continue;
|
|
323587
|
+
const prefixed = `${ep.label}/${originalId}`;
|
|
323588
|
+
modelRouteMap.set(prefixed, { endpoint: ep, originalId });
|
|
323589
|
+
out.push({
|
|
323590
|
+
name: prefixed,
|
|
323591
|
+
model: prefixed,
|
|
323592
|
+
modified_at: String(m2.modified_at ?? nowIso),
|
|
323593
|
+
size: Number(m2.size ?? 0),
|
|
323594
|
+
digest: String(m2.digest ?? ""),
|
|
323595
|
+
details: {
|
|
323596
|
+
parent_model: m2.details?.parent_model,
|
|
323597
|
+
format: String(m2.details?.format ?? "gguf"),
|
|
323598
|
+
family: String(m2.details?.family ?? ""),
|
|
323599
|
+
families: Array.isArray(m2.details?.families) ? m2.details.families : [],
|
|
323600
|
+
parameter_size: String(m2.details?.parameter_size ?? ""),
|
|
323601
|
+
quantization_level: String(m2.details?.quantization_level ?? "")
|
|
323602
|
+
}
|
|
323603
|
+
});
|
|
323604
|
+
}
|
|
323605
|
+
} else {
|
|
323606
|
+
const models = Array.isArray(body.data) ? body.data : [];
|
|
323607
|
+
for (const m2 of models) {
|
|
323608
|
+
const originalId = String(m2.id ?? m2.name ?? "");
|
|
323609
|
+
if (!originalId) continue;
|
|
323610
|
+
const prefixed = `${ep.label}/${originalId}`;
|
|
323611
|
+
modelRouteMap.set(prefixed, { endpoint: ep, originalId });
|
|
323612
|
+
const created = Number(m2.created ?? 0);
|
|
323613
|
+
out.push({
|
|
323614
|
+
name: prefixed,
|
|
323615
|
+
model: prefixed,
|
|
323616
|
+
modified_at: created > 0 ? new Date(created * 1e3).toISOString() : nowIso,
|
|
323617
|
+
size: 0,
|
|
323618
|
+
digest: "",
|
|
323619
|
+
details: {
|
|
323620
|
+
format: "api",
|
|
323621
|
+
family: ep.type || "unknown",
|
|
323622
|
+
families: [ep.type || "unknown"],
|
|
323623
|
+
parameter_size: "",
|
|
323624
|
+
quantization_level: ""
|
|
323625
|
+
}
|
|
323626
|
+
});
|
|
323627
|
+
}
|
|
323628
|
+
}
|
|
323629
|
+
} catch {
|
|
323630
|
+
}
|
|
323631
|
+
});
|
|
323632
|
+
await Promise.allSettled(fetches);
|
|
323633
|
+
return out.sort((a2, b) => a2.name.localeCompare(b.name));
|
|
323634
|
+
}
|
|
323635
|
+
async function handleApiTags(res) {
|
|
323636
|
+
try {
|
|
323637
|
+
const models = await fetchAggregatedOllamaTags();
|
|
323638
|
+
jsonResponse(res, 200, { models });
|
|
323639
|
+
} catch (err) {
|
|
323640
|
+
jsonResponse(res, 502, {
|
|
323641
|
+
error: "Failed to fetch tags",
|
|
323642
|
+
message: err instanceof Error ? err.message : String(err)
|
|
323643
|
+
});
|
|
323644
|
+
}
|
|
323645
|
+
}
|
|
323530
323646
|
async function handleV1ChatCompletions(req2, res, ollamaUrl) {
|
|
323531
323647
|
const body = await parseJsonBody(req2);
|
|
323532
323648
|
if (!body || typeof body !== "object") {
|
|
@@ -325764,6 +325880,10 @@ ${steering}`;
|
|
|
325764
325880
|
await handleV1Models(res, ollamaUrl);
|
|
325765
325881
|
return;
|
|
325766
325882
|
}
|
|
325883
|
+
if (pathname === "/api/tags" && method === "GET") {
|
|
325884
|
+
await handleApiTags(res);
|
|
325885
|
+
return;
|
|
325886
|
+
}
|
|
325767
325887
|
if (pathname === "/v1/chat/completions" && method === "POST") {
|
|
325768
325888
|
await handleV1ChatCompletions(req2, res, ollamaUrl);
|
|
325769
325889
|
return;
|
package/package.json
CHANGED