Commit Graph

30849 Commits

Author SHA1 Message Date
Peter Steinberger
116c600f60 fix: treat zero-rate usage cost as unknown 2026-05-25 23:06:44 +01:00
Michael Zelbel
9c79a0f8f4 fix(usage-cost): invalidate durable cache on missing-cost semantics change
Bump USAGE_COST_CACHE_VERSION 3->4 so a warm .usage-cost-cache.json written by a
pre-change build is rebuilt instead of serving stale complete-$0 totals after
upgrade (the new missing-cost branch otherwise only runs when a file is rescanned).
Add a regression test asserting an older-version cache is treated as stale for an
unpriced session.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 23:06:44 +01:00
Michael Zelbel
16702496c6 fix(usage-cost): only flag catalog-default zeros, preserve operator-configured $0
Address review: distinguish unknown pricing from an intentional free price. A
turn's all-zero cost is treated as unknown (counted toward missingCostEntries)
only when the operator did NOT explicitly configure the model's price under
models.providers -- i.e. the zero is a generated-catalog default (codex/gpt-5.x),
not a deliberate $0. Operator-configured zero-cost models keep reporting a
complete $0.

Adds resolveConfiguredModelCost() to read config-only pricing, and regression
tests for both paths (unconfigured unknown -> missing; configured free -> $0).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 23:06:44 +01:00
Michael Zelbel
6e85869161 fix(usage-cost): preserve transport-recorded positive cost for unpriced models
Only treat an unpriced (all-zero) model's turn as missing when it has no
trustworthy recorded cost (recorded cost is 0 or absent). A turn carrying a
real positive recorded cost is preserved, fixing a regression where priced
fixtures without explicit pricing config lost their recorded cost.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 23:06:44 +01:00
Michael Zelbel
1cc0a96df1 fix(usage-cost): surface unpriced-model spend as missingCostEntries instead of $0
Models that ship an all-zero cost block (e.g. codex gpt-5.5, whose Codex
backend exposes no per-token price) made usage-cost report totalCost: 0 with
missingCostEntries: 0 -- a confident, complete $0 -- so every budget/spike
safeguard keyed off totalCost was silently blind to real pay-per-token spend.

scanTranscriptFile now treats a resolved cost config with no positive per-token
rate (and no tiered pricing) as "pricing unknown": for turns that burned tokens
it drops the transport's fabricated $0 and surfaces the turn as a missing-cost
entry, mirroring the existing tiered-pricing override. Models with positive or
tiered pricing and zero-token entries are unaffected.

Verified on a real OpenClaw 2026.5.20 host (default openai/gpt-5.5, api_key):
1,780,235 tokens that previously reported missingCostEntries 0 now report 32.

Related: #85858

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 23:06:44 +01:00
clawsweeper[bot]
55c9a6beea fix(agents): strip markdown code spans from IDENTITY.md values and labels (#86647)
Summary:
- The PR updates `src/agents/identity-file.ts` to normalize backtick-wrapped IDENTITY.md labels and values, and adds parser/merge regression tests in `src/agents/identity-file.test.ts`.
- PR surface: Source +8, Tests +28. Total +36 across 2 files.
- Reproducibility: yes. source-reproducible with high confidence: current main strips `*` and `_` but not back ... e unnormalized string. I did not run tests because this review was required to keep the checkout read-only.

Automerge notes:
- PR branch already contained follow-up commit before automerge: fix(agents): strip markdown code spans from IDENTITY.md values and la…

Validation:
- ClawSweeper review passed for head 30c43defd6.
- Required merge gates passed before the squash merge.

Prepared head SHA: 30c43defd6
Review: https://github.com/openclaw/openclaw/pull/86647#issuecomment-4537456646

Co-authored-by: nayrosk <105997554+nayrosk@users.noreply.github.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com>
Approved-by: takhoffman
Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
2026-05-25 22:00:36 +00:00
Peter Steinberger
5b6d03e3e2 perf: reduce runtime cache churn
Reduce hot-path cache churn by reusing the active plugin metadata snapshot for manifest model-id normalization when safe, and by avoiding repeated JSON reparses for cached session stores while preserving clone semantics.

Verification:
- pnpm exec oxfmt --check src/plugins/manifest-model-id-normalization.ts src/plugins/manifest-model-id-normalization.test.ts src/config/sessions/store-cache.ts src/config/sessions.cache.test.ts
- node scripts/run-vitest.mjs src/config/sessions.cache.test.ts src/plugins/manifest-model-id-normalization.test.ts src/gateway/session-utils.subagent.test.ts
- pnpm tsgo:core
- autoreview clean
- PR CI green
2026-05-25 22:40:46 +01:00
Zee Zheng
0d4575a241 fix(pi-runner): flush blocks after compaction retry (#85288) (thanks @spacegeologist)
Behavior addressed: Embedded PI compaction retry now drains block replies again after the retry wait resolves, so retry-generated replies are not left behind while preserving aggregate-timeout fallback behavior.
Real environment tested: local OpenClaw focused Pi runner test shard plus contributor local live-output proof in the PR body.
Exact steps or command run after this patch: pnpm test src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts src/agents/pi-embedded-runner/run/compaction-retry-aggregate-timeout.test.ts; .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main
Evidence after fix: 2 test files passed, 55 tests passed; final autoreview clean with no accepted/actionable findings.
Observed result after fix: the runner flushes before the compaction wait, waits for compaction retry, then performs a second idempotent flush when the wait resolves without timing out.
What was not tested: fresh external-channel live retry by this agent; PR retains contributor live-output proof for the delayed channel adapter path.

Thanks @spacegeologist.

Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com>
2026-05-25 22:27:29 +01:00
Vincent Koc
a122d804dd fix(gateway): abort stale agent runs on restart 2026-05-25 23:26:10 +02:00
Merlin
f4cfa012e1 fix(openai): route compaction through Codex auth provider (#86408)
* fix(openai): route compaction through codex auth provider

Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>

* fix(openai): honor default responses compaction threshold

Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>

* fix(openai): preserve codex runtime routing

* docs(changelog): note Codex routing fix

---------

Co-authored-by: Merlin <258679497+funmerlin@users.noreply.github.com>
Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-05-25 22:13:08 +01:00
Peter Steinberger
5dccba7405 refactor: share realtime forced consult coordination 2026-05-25 22:02:19 +01:00
Vincent Koc
f6a49a4e8a test(qa-lab): add runtime confidence reports 2026-05-25 22:00:21 +01:00
Peter Steinberger
9f7485e182 test: port release validation stabilizers 2026-05-25 21:50:49 +01:00
Bryan P
c51fa0d127 fix(cron): stop forcing message tool for delivery
Keep isolated cron announce delivery owned by runner fallback while leaving agent-initiated message sends optional. `delivery.mode: none` no longer forces message delivery, announce delivery skips fallback only after a verified same-target message-tool send, and prompt allowlist checks now match runtime tool policy normalization/group expansion.

Verified with focused cron tests, `check:changed`, autoreview, and PR CI on 7ab77bad97.

Thanks @bryanpearson.

Co-authored-by: bryanpearson <bryanmpearson@gmail.com>
2026-05-25 21:46:51 +01:00
Neerav Makwana
148db14736 fix(google): omit request config with cached content
Fix Gemini cached-content GenerateContent payloads so cached requests no longer resend request-level systemInstruction, tools, or toolConfig.

Covers explicit cachedContent and managed cacheRetention prompt caching; fixes #84919.

Proof: Real behavior proof passed on PR head 198a42bbc6 after live Gemini repro/fix evidence was added to the PR body. Focused tests and check:changed were already green.

Thanks @neeravmakwana.
2026-05-25 21:42:21 +01:00
Peter Steinberger
4e9dac5e00 fix(discord): stabilize realtime wake-name feedback 2026-05-25 21:24:06 +01:00
Galin Iliev
b30f8e5290 test(config): guard legacy agentRuntime regression
Adds regression coverage for agents.defaults.agentRuntime schema acceptance and invalid-config doctor fix reachability.

The runtime behavior fix already landed on main in 5b9be2cdb1c01a2896783c52f5f0654c5f22a249; this PR locks the expected behavior with focused tests.

Closes #72872
2026-05-25 13:23:59 -07:00
Peter Steinberger
2afb8198c1 perf: precompute audio resample kernels
Precompute FIR resample kernels for common voice sample-rate conversions to avoid per-sample trigonometry while preserving output for tested ratios.\n\nVerification: node scripts/run-vitest.mjs extensions/voice-call/src/telephony-audio.test.ts; pnpm tsgo:core; autoreview --mode commit --commit HEAD; PR CI green.
2026-05-25 21:22:09 +01:00
Peter Steinberger
009b18c1f4 fix(codex): allow env api-key app-server bootstrap 2026-05-25 21:21:01 +01:00
Peter Steinberger
77d9ac30bb refactor: reuse shared coercion helpers (#86419)
* refactor: share talk event metric extraction

* refactor: reuse shared coercion helpers

* refactor: reuse shared primitive guards

* refactor: reuse shared record guard

* refactor: reuse shared primitive helpers

* refactor: reuse shared string guards

* refactor: reuse shared non-empty string guard

* refactor: share plugin primitive coercion helpers

* refactor: reuse plugin coercion helpers

* refactor: reuse plugin coercion helpers in more plugins

* refactor: reuse channel coercion helpers

* refactor: reuse monitor coercion helpers

* refactor: reuse provider coercion helpers

* refactor: reuse core coercion helpers

* refactor: reuse runtime coercion helpers

* refactor: reuse helper coercion in codex paths

* refactor: reuse helper coercion in runtime paths

* refactor: reuse codex app-server coercion helpers

* refactor: reuse codex record helpers

* refactor: reuse migration and qa record helpers

* refactor: reuse feishu and core helper guards

* refactor: reuse browser and policy coercion helpers

* refactor: reuse memory wiki record helper

* refactor: share boolean coercion helpers

* refactor: reuse finite number coercion

* refactor: reuse trimmed string list helpers

* refactor: reuse string list normalization

* refactor: reuse remaining string list helpers

* refactor: reuse string entry normalizer

* refactor: share sorted string helpers

* refactor: share string list normalization

* test: preserve command registry browser imports

* refactor: reuse trimmed list helpers

* refactor: reuse string dedupe helpers

* refactor: reuse local dedupe helpers

* refactor: reuse more string dedupe helpers

* refactor: reuse command string dedupe helpers

* refactor: dedupe memory path lists with helper

* refactor: expose string dedupe helpers to plugins

* refactor: reuse core string dedupe helpers

* refactor: reuse shared unique value helpers

* refactor: reuse unique helpers in agent utilities

* refactor: reuse unique helpers in config plumbing

* refactor: reuse unique helpers in extensions

* refactor: reuse unique helpers in core utilities

* refactor: reuse unique helpers in qa plugins

* refactor: reuse unique helpers in memory plugins

* refactor: reuse unique helpers in channel plugins

* refactor: reuse unique helpers in core tails

* refactor: reuse unique helper in comfy workflow

* refactor: reuse unique helpers in test utilities

* refactor: expose unique value helper to plugins

* refactor: reuse unique helpers for numeric lists

* refactor: replace index dedupe filters

* refactor: reuse string entry normalization

* refactor: reuse string normalization in plugin helpers

* refactor: reuse string normalization in extension helpers

* refactor: reuse string normalization in channel parsers

* refactor: reuse string normalization in memory search

* refactor: reuse string normalization in provider parsers

* refactor: reuse string normalization in qa helpers

* refactor: reuse string normalization in infra parsers

* refactor: reuse string normalization in messaging parsers

* refactor: reuse string normalization in core parsers

* refactor: reuse string normalization in extension parsers

* refactor: reuse string normalization in remaining parsers

* refactor: reuse string normalization in final parser spots

* refactor: reuse string normalization in qa media helpers

* refactor: reuse normalization in provider and media lists

* refactor: reuse normalization for remaining set filters

* refactor: reuse normalization in policy allowlists

* refactor: reuse normalization in session and owner lists

* refactor: centralize primitive string lists

* refactor: reuse lowercase entry helpers

* refactor: reuse sorted string helpers

* refactor: reuse unique trimmed helpers

* refactor: reuse string normalization helpers

* refactor: reuse catalog string helpers

* refactor: reuse remaining string helpers

* refactor: simplify remaining list normalization

* refactor: reuse codex auth order normalization

* chore: refresh plugin sdk api baseline

* fix: make shared string sorting deterministic

* chore: refresh plugin sdk api baseline

* fix: align host env security ordering
2026-05-25 21:20:41 +01:00
Peter Steinberger
a98660eebd fix(cron): preserve runtime snapshot for isolated delivery
Fix isolated cron delivery so agent-default derivation keeps using the paired runtime config snapshot, preserving resolved channel credentials such as Discord SecretRefs. Fixes #86545.
2026-05-25 21:10:14 +01:00
Vincent Koc
c55bee5ec7 fix(test): model active assistant failover attempts 2026-05-25 22:03:03 +02:00
Peter Steinberger
aa05c5c9dd test: fix mock signatures for tsgo 2026-05-25 20:57:08 +01:00
Sebastien Tardif
36f269d60b docs: document fail-closed behavior for rejected modelPatterns
Add inline comment explaining that compileSafeRegex rejects patterns
with nested repetition (ReDoS risk) and returns null. Rejected patterns
are silently skipped; the plugin will not match via that pattern but
other patterns and prefixes still apply.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-25 20:57:04 +01:00
Sebastien Tardif
117e08240b fix(security): guard plugin modelPatterns with compileSafeRegex
Replace raw `new RegExp(patternSource, "u")` in
`resolveModelSupportMatchKind` with the existing
`compileSafeRegex()` guard from `src/security/safe-regex.ts`.

A malicious or careless plugin manifest pattern like `(a+)+$`
causes catastrophic backtracking (ReDoS) against non-matching model
IDs. `compileSafeRegex` detects nested repetition and returns null,
which the caller now treats as a non-match (equivalent to the
previous catch-continue for invalid regex).

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-25 20:57:04 +01:00
Sebastien Tardif
9a6c16130a style: use bracket notation for __openclaw to satisfy no-underscore-dangle
Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-25 20:57:01 +01:00
Sebastien Tardif
aff8e644fc test: tighten oversized metadata assertion to check exact id in __openclaw
Replace string containment check with direct field assertions:
- oversized.role is 'assistant'
- __openclaw.id is 'oversized-child' (exact match)
- parentId extraction proven by record inclusion in active tree

5/5 oversized transcript tests pass.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-25 20:57:01 +01:00
Sebastien Tardif
fe8d99d421 fix(security): escape field names in transcript regex extraction
extractJsonStringFieldPrefix and extractJsonNullableStringFieldPrefix
interpolate the `field` parameter into `new RegExp(...)` without
escaping.  All current callers pass hardcoded strings ("id",
"parentId", "type", "role"), but the function signature accepts
any string.  A future caller passing a field containing regex
metacharacters (e.g. "foo.bar") would match unintended patterns.

Wrap the interpolation with escapeRegExp() from src/shared/regexp.ts
so metacharacters are treated literally.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-25 20:57:01 +01:00
Peter Steinberger
78a1e7dfe6 fix(logging): keep string failure codes on EPIPE 2026-05-25 20:56:56 +01:00
Peter Steinberger
623a60a2b7 fix(logging): preserve failure exit on EPIPE 2026-05-25 20:56:56 +01:00
Pavel Zakharov
2aa5f1771f fix(logging): exit on stdout/stderr EPIPE instead of spinning
When the gateway process is orphaned after a systemd service restart,
the parent's journal pipe closes and every write to stdout/stderr returns
EPIPE. The previous handler swallowed it with a bare return, so background
loops (config file watcher, etc.) kept firing and the process spun at
100% CPU indefinitely.

Exit cleanly with code 0 instead — a process whose own output streams
are broken has nowhere to log and no reason to keep running.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 20:56:56 +01:00
Peter Steinberger
c88f660258 test(gateway): pin live gateway models to pi runtime 2026-05-25 20:37:33 +01:00
Peter Steinberger
a0023fbfa0 perf: speed up local TUI startup 2026-05-25 20:30:00 +01:00
Peter Steinberger
d0ab0d9922 refactor: share realtime voice activation helpers (#86615) 2026-05-25 20:25:17 +01:00
Peter Steinberger
f00a912c25 fix: tighten Discord voice wake matching (#86595)
* fix: tighten Discord voice wake matching

* test: avoid wildcard model runtime normalization
2026-05-25 19:51:32 +01:00
Peter Steinberger
baab4cf045 refactor(logging): share diagnostic message lifecycle
Refactor diagnostic queued/state/processed emission into a shared helper used by dispatch and isolated cron turns.

Preserve dispatch processed-event behavior, cron queue-depth symmetry, and final cron session-id adoption while adding focused helper coverage and reviewer comments for the non-obvious invariants.
2026-05-25 19:48:45 +01:00
Vincent Koc
e844d1d6e5 fix(cron): restore suspended lanes to default concurrency 2026-05-25 20:39:37 +02:00
Dallin Romney
a61d5308b5 fix(auth): emit one-shot doctor-pointer warning for Keychain-only legacy Codex OAuth profiles (#86220) 2026-05-25 11:39:32 -07:00
Peter Steinberger
9b9d8970b0 fix(codex): recover stale preflight bindings (#86602)
Fixes #86211.
Recreates the focused recovery from #86216 with maintainer-side tests.

Co-authored-by: Paul Frederiksen <paul@paulfrederiksen.com>
2026-05-25 19:37:49 +01:00
Peter Steinberger
8351556059 test(cron): pin sequential duration regression 2026-05-25 19:23:47 +01:00
IWhatsskill
985bc934a1 fix(cron): canonicalize preserved row ids 2026-05-25 19:23:47 +01:00
IWhatsskill
c916906584 fix(cron): preserve unsupported payload rows on writes 2026-05-25 19:23:47 +01:00
brokemac79
1e188bcda9 fix(status): prefer active OAuth for runtime aliases
Prefer the active Claude CLI OAuth auth label when the configured Anthropic model resolves through an equivalent Claude CLI runtime alias, so `/status` no longer reports an unused env API-key label.

Also adds regression coverage for both text and message status renderers, plus the maintainer changelog entry.

Closes #80184.

Co-authored-by: brokemac79 <martin_cleary@yahoo.co.uk>
2026-05-25 19:19:51 +01:00
Sebastien Tardif
915c820c38 fix(google): stop appending preview to flash lite
Normalize Google Gemini 3.1 Flash Lite routing to the GA model id and keep the retired preview spelling as a compatibility alias. Align default alias docs, FAQ guidance, and deprecated-model manifest recommendations with the GA id.

Fixes #86151.

Co-authored-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-25 19:12:36 +01:00
Peter Steinberger
baf469f02e fix(agents): notify stale cron media failures 2026-05-25 19:04:03 +01:00
Peter Steinberger
f01b2a8eab fix(agents): deliver stale cron media completions 2026-05-25 19:04:03 +01:00
ai-hpc
f5d2db2a60 fix(agents): keep cron media completions run-scoped 2026-05-25 19:04:03 +01:00
tianxiaochannel-oss88
9445960d9d guide workspace-only scratch paths 2026-05-25 19:03:57 +01:00
Peter Steinberger
207a5a2983 fix(cron): report rotated session in final diagnostics 2026-05-25 19:03:50 +01:00
Arnab Saha
48532227d5 fix(cron): gate lifecycle diagnostic events behind isDiagnosticsEnabled
Address clawsweeper P2: cron isolated-agent lifecycle (message.queued,
session.state, message.processed) now mirrors the dispatch path and
respects the diagnostics.enabled master toggle. Added regression test
for the disabled-config path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 19:03:50 +01:00