Skip to content

feat(gateway): add usage report rpc - #3

Merged
cryptolir merged 1 commit into
mainfrom
codex/system-reports
Mar 27, 2026
Merged

cryptolir merged 1 commit into
mainfrom
codex/system-reports

Conversation

@cryptolir

Copy link
Copy Markdown
Owner

Summary

  • add a new usage.report gateway RPC for full-window usage reporting
  • aggregate by-model and by-provider totals across all matching sessions
  • cover the new RPC with a targeted gateway test

Testing

  • bunx vitest run src/gateway/server-methods/usage.report.test.ts
  • pnpm build

@cryptolir
cryptolir marked this pull request as ready for review March 27, 2026 21:46
@cryptolir
cryptolir merged commit 09f6843 into main Mar 27, 2026
2 of 9 checks passed
@cryptolir
cryptolir deleted the codex/system-reports branch March 27, 2026 21:48
cryptolir pushed a commit that referenced this pull request Jun 17, 2026
Three P2 fixes to the load_skill app-session path:
- [#1] derive appSkillLoad from the FINAL tool list (tools.some(load_skill)) rather
  than just appUserId, and suppress the app skills section when load_skill was
  filtered out by tool policy — so the model is never told to call a tool it does
  not have. The skills prompt is now built after tool creation in both attempt.ts
  and compact.ts.
- [#2] mirror the whole app-session skill branch in compact.ts, so app-user
  COMPACTION also gets the path-free app prompt + load-by-name (no <location> leak,
  no loss of the load_skill behavior).
- [#3] new limitAppSkills() applies the same maxSkillsInPrompt/char caps as the
  normal prompt; both the app prompt and the load_skill allowlist are built from it,
  so an app session can neither see nor load more skills than a normal prompt shows.

Gate: vitest load-skill 11 + system-prompt.skills 8 (+2 limitAppSkills) +
overflow-compaction; tsgo clean on touched files; oxlint --type-aware 0/0; oxfmt.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
cryptolir added a commit that referenced this pull request Jun 18, 2026
…) (#74)

* feat(skills): load_skill tool for app-user sessions (live skills, jailed)

App-user sessions run jailed (tools.fs.workspaceOnly) and cannot read the shared
SKILL.md by path, so the live dashboard skills listed in their prompt were
unusable (the reason the Havaya Drive method was hard-embedded). Add a read-only,
name-scoped load_skill tool that resolves a skill NAME — from the same filtered,
prompt-visible set the model is shown — to its SKILL.md content, read server-side.
The per-user file jail is untouched.

Implements docs/experiments/plans/app-user-skill-access.md (Option A) with the
codex 4517821566 refinements:
- allowlist = the snapshot's resolvedSkills (filtered/prompt-visible), so it is
  never a side channel to disableModelInvocation/ineligible skills (#2);
- confinement against the matched entry's own baseDir, not a hardcoded path, so
  multi-root (bundled/managed/workspace) skills resolve; symlink-escape rejected (#1);
- gated on a resolved app user via resolveAppUserId ?? appUserIdFromSessionKey
  (turn-1-safe, excludes _no-app-user) (#3);
- 24KB cap + truncated flag; no sibling files in v1 (#4).
The app skills prompt lists name+description only (no <location>, no host-path
leak) and instructs the model to call load_skill; normal sessions unchanged.

Files: new src/agents/tools/load-skill.ts; buildAppSkillsPrompt in
skills/workspace.ts; buildSkillsSection app branch (system-prompt.ts) threaded via
buildEmbeddedSystemPrompt; appSkills wired through pi-tools -> openclaw-tools;
attempt.ts resolves the app user, builds the single skills source, and branches.

Gate: vitest load-skill 11 + system-prompt.skills 6 + save-user-section 13
(unchanged); tsgo clean on touched files; oxlint --type-aware 0/0; oxfmt.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(skills): address codex 4519976882 — tool-filter, compaction, limits

Three P2 fixes to the load_skill app-session path:
- [#1] derive appSkillLoad from the FINAL tool list (tools.some(load_skill)) rather
  than just appUserId, and suppress the app skills section when load_skill was
  filtered out by tool policy — so the model is never told to call a tool it does
  not have. The skills prompt is now built after tool creation in both attempt.ts
  and compact.ts.
- [#2] mirror the whole app-session skill branch in compact.ts, so app-user
  COMPACTION also gets the path-free app prompt + load-by-name (no <location> leak,
  no loss of the load_skill behavior).
- [#3] new limitAppSkills() applies the same maxSkillsInPrompt/char caps as the
  normal prompt; both the app prompt and the load_skill allowlist are built from it,
  so an app session can neither see nor load more skills than a normal prompt shows.

Gate: vitest load-skill 11 + system-prompt.skills 8 (+2 limitAppSkills) +
overflow-compaction; tsgo clean on touched files; oxlint --type-aware 0/0; oxfmt.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* docs(skills): clarify the load_skill allowlist is the prompt-limited subset

Codex recheck 4520156223 non-blocking nit: comments in load-skill.ts and the
appSkills option docs (openclaw-tools.ts, pi-tools.ts) described the allowlist as
the snapshot's resolvedSkills; after the limit fix it is the prompt-limited subset
(via limitAppSkills). Comment-only; keeps the security invariant easy to audit.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Liran Peretz <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
cryptolir pushed a commit that referenced this pull request Jun 30, 2026
- explicit rollout order testingbot -> rest of EU -> US (Codex #1); restart-drain
  kept as a separate manual stopgap.
- clarify the cap bounds old-space-driven RSS, not total RSS; canary verifies
  actual RSS/swap (Codex #2).
- 'more than 1 GB' instead of '> 1 GB' so check-docs stops parsing a blockquote (Codex #3).
- quote the env value; keep 512 (not 384).
- add profiling finding: memory is activity-driven reclaimable working-state
  (idle 29 MiB/8d vs busy 480-950 MiB; restart 949->368 MiB), not disk files,
  not a V8 time-ratchet; leak-vs-bounded unproven (USR1=restart blocks inspector).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant