@rowan-agent/agent 0.25.1 → 0.26.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.
- package/dist/index.js +28 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2499,13 +2499,10 @@ function createCompactPhase() {
|
|
|
2499
2499
|
const tools = context.tools.filter((tool) => tool.name === "read" || tool.name === "bash");
|
|
2500
2500
|
const working = { ...context, tools, skills: [...context.skills], messages: [...context.messages] };
|
|
2501
2501
|
const instructions = compactInstructions(context);
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
phase: COMPACT_PHASE_ID
|
|
2507
|
-
}));
|
|
2508
|
-
}
|
|
2502
|
+
working.messages.push(createMessage("user", buildCompactionPrompt(instructions), {
|
|
2503
|
+
kind: "phase_input",
|
|
2504
|
+
phase: COMPACT_PHASE_ID
|
|
2505
|
+
}));
|
|
2509
2506
|
let result = await execution.invokeModel(working, { output: "internal" });
|
|
2510
2507
|
for (let attempt = 0; attempt < 8 && result.toolCalls.length > 0; attempt += 1) {
|
|
2511
2508
|
const calls = result.toolCalls.filter((call) => tools.some((tool) => tool.name === call.name));
|
|
@@ -2525,26 +2522,16 @@ ${instructions}`, {
|
|
|
2525
2522
|
kind: "phase_tool",
|
|
2526
2523
|
phase: COMPACT_PHASE_ID
|
|
2527
2524
|
}));
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
});
|
|
2536
|
-
} catch (error) {
|
|
2537
|
-
toolResult2 = {
|
|
2538
|
-
toolCallId: call.id,
|
|
2539
|
-
toolName: call.name,
|
|
2540
|
-
ok: false,
|
|
2541
|
-
content: null,
|
|
2542
|
-
error: error instanceof Error ? error.message : String(error)
|
|
2543
|
-
};
|
|
2544
|
-
}
|
|
2525
|
+
const toolResults = await execution.executeTools(
|
|
2526
|
+
working,
|
|
2527
|
+
normalizedCalls,
|
|
2528
|
+
result.contentBlocks,
|
|
2529
|
+
result.model ? { model: result.model, usage: result.usage } : void 0
|
|
2530
|
+
);
|
|
2531
|
+
for (const toolResult2 of toolResults) {
|
|
2545
2532
|
working.messages.push(createMessage("tool", [{
|
|
2546
2533
|
type: "tool_result",
|
|
2547
|
-
toolUseId:
|
|
2534
|
+
toolUseId: toolResult2.toolCallId,
|
|
2548
2535
|
content: JSON.stringify(toolResult2),
|
|
2549
2536
|
isError: !toolResult2.ok
|
|
2550
2537
|
}], {
|
|
@@ -2571,6 +2558,22 @@ ${instructions}`, {
|
|
|
2571
2558
|
}
|
|
2572
2559
|
};
|
|
2573
2560
|
}
|
|
2561
|
+
function buildCompactionPrompt(instructions) {
|
|
2562
|
+
const lines = [
|
|
2563
|
+
"The conversation above is to be summarized, not continued. Do not answer, carry out, or use Tools for any request in it.",
|
|
2564
|
+
"Output only the summary in a fixed structure:",
|
|
2565
|
+
"- Goal and state",
|
|
2566
|
+
"- Decisions with reasons",
|
|
2567
|
+
"- Open requests left unfinished",
|
|
2568
|
+
"- Files and archive references",
|
|
2569
|
+
"- Facts to keep"
|
|
2570
|
+
];
|
|
2571
|
+
if (instructions) {
|
|
2572
|
+
lines.push("", `Additional compaction instructions:
|
|
2573
|
+
${instructions}`);
|
|
2574
|
+
}
|
|
2575
|
+
return lines.join("\n");
|
|
2576
|
+
}
|
|
2574
2577
|
function compactInstructions(context) {
|
|
2575
2578
|
const payload = context.state.payload;
|
|
2576
2579
|
if (typeof payload === "object" && payload !== null && "instructions" in payload) {
|