Skip to content

perf: consolidate auth profile success writes#80375

Merged
mcaxtr merged 1 commit into
mainfrom
fix/auth-profile-success-write
May 10, 2026
Merged

perf: consolidate auth profile success writes#80375
mcaxtr merged 1 commit into
mainfrom
fix/auth-profile-success-write

Conversation

@mcaxtr

@mcaxtr mcaxtr commented May 10, 2026

Copy link
Copy Markdown
Member

Summary

  • Add markAuthProfileSuccess to record last-good auth profile and successful usage stats in one locked auth-store update.
  • Use it after successful embedded model runs instead of separate markAuthProfileGood and markAuthProfileUsed writes.
  • Add coverage for canonical provider alias handling and successful usage-stat reset.

Compatibility note

  • This intentionally removes the old markAuthProfileGood and markAuthProfileUsed exports from the deprecated openclaw/plugin-sdk/agent-runtime barrel. Repo-local usage has moved to markAuthProfileSuccess, and no in-repo imports of the old helper names remain on this PR branch.

Verification

  • git diff --check
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/agents/auth-profiles/profiles.ts src/agents/auth-profiles.ts src/agents/pi-embedded-runner/run.ts src/agents/auth-profiles/order.test.ts
  • pnpm test src/agents/auth-profiles/order.test.ts src/agents/auth-profiles/usage.test.ts
  • pnpm test test/scripts/check-changelog-attributions.test.ts src/infra/changelog-unreleased.test.ts
  • pnpm tsgo:core

@mcaxtr
mcaxtr requested a review from a team as a code owner May 10, 2026 18:13
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels May 10, 2026
@mcaxtr
mcaxtr force-pushed the fix/auth-profile-success-write branch from b9a58cd to 4a822d3 Compare May 10, 2026 18:16
@clawsweeper

clawsweeper Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge.

Summary
The PR adds markAuthProfileSuccess, uses it after embedded model success, updates auth-profile tests, and adds a changelog entry.

Reproducibility: yes. for the duplicate-write behavior: current main calls markAuthProfileGood and then markAuthProfileUsed after successful embedded runs. I did not live-measure the latency impact under read-only review constraints.

Real behavior proof
Not applicable: The external-contributor real-behavior proof gate does not apply because this is a MEMBER PR with the protected maintainer label.

Next step before merge
Protected maintainer-labeled PR has a concrete public SDK compatibility blocker; a maintainer should update the branch or explicitly approve a breaking-removal path.

Security
Cleared: The diff only changes auth-store bookkeeping, tests, runner mocks, and changelog, with no new dependency, workflow, permission, secret, or code-download surface.

Review findings

  • [P2] Preserve compatibility exports in agent-runtime — src/plugin-sdk/agent-runtime.ts:39
Review details

Best possible solution:

Keep the single locked success helper internally, but preserve deprecated markAuthProfileGood and markAuthProfileUsed compatibility exports or wrappers on the public SDK barrel until a major-version removal.

Do we have a high-confidence way to reproduce the issue?

Yes for the duplicate-write behavior: current main calls markAuthProfileGood and then markAuthProfileUsed after successful embedded runs. I did not live-measure the latency impact under read-only review constraints.

Is this the best way to solve the issue?

No as currently patched: consolidating the two writes is narrow and maintainable, but removing public SDK exports is not. The safer path is to keep deprecated compatibility exports while using markAuthProfileSuccess internally.

Full review comments:

  • [P2] Preserve compatibility exports in agent-runtime — src/plugin-sdk/agent-runtime.ts:39
    openclaw/plugin-sdk/agent-runtime is a package-exported SDK subpath, so replacing markAuthProfileGood here and dropping markAuthProfileUsed removes public symbols that third-party plugins may import. Keep the old exports as deprecated wrappers or aliases while switching OpenClaw's internal success path to markAuthProfileSuccess.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.9

What I checked:

  • Live PR metadata: The PR is open at head cfcc34f6d05a3a899876877b0a26fd61f6d5251e, has author association MEMBER, and carries the protected maintainer label. (cfcc34f6d05a)
  • Current duplicate success writes: Current main calls markAuthProfileGood and then markAuthProfileUsed after a successful embedded run with lastProfileId, so the performance target is source-reproducible. (src/agents/pi-embedded-runner/run.ts:2884, 5da90d0f4f3a)
  • Current public SDK export surface: ./plugin-sdk/agent-runtime is a package export, and current main re-exports both markAuthProfileGood and markAuthProfileUsed through that public subpath. (package.json:425, 5da90d0f4f3a)
  • SDK compatibility policy: The scoped SDK guide defines src/plugin-sdk as the public plugin contract and says breaking removals or renames are major-version work; the migration docs require compatibility adapters and deprecation windows for external plugin imports. (src/plugin-sdk/AGENTS.md:3, 5da90d0f4f3a)
  • Latest PR compatibility regression: The latest patch replaces markAuthProfileGood with markAuthProfileSuccess in src/plugin-sdk/agent-runtime.ts and removes markAuthProfileUsed from that public barrel. (src/plugin-sdk/agent-runtime.ts:39, cfcc34f6d05a)
  • Prior review context: The existing ClawSweeper comment already flagged the same SDK compatibility issue; the latest head after the later force-push still contains the removal. (cfcc34f6d05a)

Likely related people:

  • steipete: Recent history shows SDK surface reduction and auth-profile helper export work around the affected public SDK and auth-profile files. (role: recent SDK/auth area contributor; confidence: high; commits: 827b0de0ce74, 5acfc89175ae; files: src/plugin-sdk/agent-runtime.ts, src/agents/auth-profiles/usage.ts, src/agents/auth-profiles/profiles.ts)
  • mukhtharcm: Commit history ties this person to the original markAuthProfileUsed usage tracking and later multi-account rotation/race-condition work. (role: introduced related auth-profile usage behavior; confidence: high; commits: ce6c7737c171, eb5f758f6b3b; files: src/agents/auth-profiles.ts, src/agents/pi-embedded-runner.ts, src/agents/auth-profiles/usage.ts)
  • BunsDev: Recent merged work changed auth-profile routing in profiles.ts, adjacent to the helper being replaced by this PR. (role: recent auth-profile routing contributor; confidence: medium; commits: 626e07886383; files: src/agents/auth-profiles/profiles.ts)
  • mcaxtr: Beyond this PR, prior merged runtime foundation work touched src/plugin-sdk/agent-runtime.ts, the public surface affected by the review finding. (role: recent runtime contributor and PR committer; confidence: medium; commits: 5df08201ff50, cfcc34f6d05a; files: src/plugin-sdk/agent-runtime.ts)

Remaining risk / open question:

  • If merged as-is, downstream plugins importing markAuthProfileGood or markAuthProfileUsed from openclaw/plugin-sdk/agent-runtime would fail to compile or load.
  • Targeted tests and latency measurements were not run in this read-only review; the PR body lists verification commands but they were not independently executed here.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 5da90d0f4f3a.

@mcaxtr
mcaxtr force-pushed the fix/auth-profile-success-write branch from 4a822d3 to 7c18a9e Compare May 10, 2026 18:31
@mcaxtr
mcaxtr force-pushed the fix/auth-profile-success-write branch 2 times, most recently from 1c70671 to cfcc34f Compare May 10, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant