fix: align tool-result guard budget · openclaw/openclaw@1a2228d
steipete
·
2026-04-30
·
via Recent Commits to openclaw:main
File tree
src/agents/pi-embedded-runner/run
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ Docs: https://docs.openclaw.ai
|
11 | 11 | |
12 | 12 | ### Fixes |
13 | 13 | |
| 14 | +- Agents/tool-result guard: use the resolved runtime context token budget for non-context-engine tool-result overflow checks, so long tool-heavy sessions no longer compact early when `contextTokens` is larger than native `contextWindow`. Fixes #74917. Thanks @kAIborg24. |
14 | 15 | - Gateway/systemd: exit with sysexits 78 for supervised lock and `EADDRINUSE` conflicts so `RestartPreventExitStatus=78` stops `Restart=always` restart loops instead of repeatedly reloading plugins against an occupied port. Fixes #75115. Thanks @yhyatt. |
15 | 16 | - Plugins/runtime-deps: replace stale symlinked mirror target roots before writing runtime-mirror temp files and skip rewriting already materialized hardlinks, so cross-version container upgrades no longer crash-loop on read-only image-layer paths while warm mirrors do less churn. Fixes #75108; refs #75069. Thanks @coletebou and @xiaohuaxi. |
16 | 17 | - Auto-reply/group chats: fall back to automatic source delivery when a channel precomputes message-tool-only replies but the `message` tool is unavailable, so Discord/Slack-style group turns do not silently complete without a visible reply. Fixes #74868. Thanks @kagura-agent. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -869,3 +869,43 @@ describe("runEmbeddedAttempt context engine mid-turn precheck integration", () =
|
869 | 869 | expect(result.messagesSnapshot).toEqual([seedMessage]); |
870 | 870 | }); |
871 | 871 | }); |
| 872 | + |
| 873 | +describe("runEmbeddedAttempt tool-result guard budget wiring", () => { |
| 874 | +const sessionKey = "agent:main:guildchat:channel:tool-result-guard-budget"; |
| 875 | +const tempPaths: string[] = []; |
| 876 | + |
| 877 | +beforeEach(() => { |
| 878 | +resetEmbeddedAttemptHarness(); |
| 879 | +clearMemoryPluginState(); |
| 880 | +}); |
| 881 | + |
| 882 | +afterEach(async () => { |
| 883 | +await cleanupTempPaths(tempPaths); |
| 884 | +clearMemoryPluginState(); |
| 885 | +vi.restoreAllMocks(); |
| 886 | +}); |
| 887 | + |
| 888 | +it("uses the resolved contextTokenBudget before model contextWindow", async () => { |
| 889 | +await createContextEngineAttemptRunner({ |
| 890 | +contextEngine: createContextEngineBootstrapAndAssemble(), |
| 891 | + sessionKey, |
| 892 | + tempPaths, |
| 893 | +attemptOverrides: { |
| 894 | +contextTokenBudget: 1_000_000, |
| 895 | +model: { |
| 896 | +api: "openai-completions", |
| 897 | +provider: "openai", |
| 898 | +compat: {}, |
| 899 | +contextWindow: 200_000, |
| 900 | +input: ["text"], |
| 901 | +} as never, |
| 902 | +}, |
| 903 | +}); |
| 904 | + |
| 905 | +expect(hoisted.installToolResultContextGuardMock).toHaveBeenCalledWith( |
| 906 | +expect.objectContaining({ |
| 907 | +contextWindowTokens: 1_000_000, |
| 908 | +}), |
| 909 | +); |
| 910 | +}); |
| 911 | +}); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1528,7 +1528,12 @@ export async function runEmbeddedAttempt(
|
1528 | 1528 | }; |
1529 | 1529 | const contextTokenBudgetForGuard = Math.max( |
1530 | 1530 | 1, |
1531 | | -Math.floor(params.contextTokenBudget ?? DEFAULT_CONTEXT_TOKENS), |
| 1531 | +Math.floor( |
| 1532 | +params.contextTokenBudget ?? |
| 1533 | +params.model.contextWindow ?? |
| 1534 | +params.model.maxTokens ?? |
| 1535 | +DEFAULT_CONTEXT_TOKENS, |
| 1536 | +), |
1532 | 1537 | ); |
1533 | 1538 | const toolResultMaxCharsForGuard = resolveLiveToolResultMaxChars({ |
1534 | 1539 | contextWindowTokens: contextTokenBudgetForGuard, |
@@ -1544,12 +1549,7 @@ export async function runEmbeddedAttempt(
|
1544 | 1549 | if (!activeContextEngine || activeContextEngine.info.ownsCompaction !== true) { |
1545 | 1550 | removeToolResultContextGuard = installToolResultContextGuard({ |
1546 | 1551 | agent: activeSession.agent, |
1547 | | -contextWindowTokens: Math.max( |
1548 | | -1, |
1549 | | -Math.floor( |
1550 | | -params.model.contextWindow ?? params.model.maxTokens ?? DEFAULT_CONTEXT_TOKENS, |
1551 | | -), |
1552 | | -), |
| 1552 | +contextWindowTokens: contextTokenBudgetForGuard, |
1553 | 1553 | ...(midTurnPrecheckEnabled |
1554 | 1554 | ? { |
1555 | 1555 | midTurnPrecheck: { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。