[codex] Preserve workspace metadata reuse for model refreshes#77554
[codex] Preserve workspace metadata reuse for model refreshes#77554
Conversation
|
Codex review: needs changes before merge. Summary Reproducibility: yes. from source inspection: Next step before merge Security Review findings
Review detailsBest possible solution: Thread a trusted agent id or already resolved workspace from Do we have a high-confidence way to reproduce the issue? Yes, from source inspection: Is this the best way to solve the issue? No. Passing Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 43b5df729593. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b81feddf64
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const sessionAgentId = resolveSessionAgentId({ | ||
| sessionKey: params.sessionKey, | ||
| config: params.cfg, | ||
| }); | ||
| const workspaceDir = resolveAgentWorkspaceDir(params.cfg, sessionAgentId); |
There was a problem hiding this comment.
Resolve BTW workspace from the command agent
When /btw runs for a non-default agent without a sessionKey, commands-btw.ts already resolves agentDir from params.agentId, but this new workspace resolution only sees sessionKey and falls back to the default agent. In that scenario ensureOpenClawModelsJson is called for the non-default agent directory with the default agent's workspace, so workspace-scoped plugin model metadata can be reused or generated for the wrong workspace and written into the worker agent's models.json. Pass the command/session agent (or the already-resolved workspace) through instead of recomputing it from sessionKey alone.
Useful? React with 👍 / 👎.
b81fedd to
a0db1e7
Compare
Summary
Root Cause
Some hot model setup paths called
ensureOpenClawModelsJson(config, agentDir)after the runtime had already resolved the effective workspace. Because the workspace scope was dropped,getCurrentPluginMetadataSnapshotcould reject the current workspace-scoped snapshot and force plugin metadata reconstruction.This keeps the existing workspace-safety boundary: callers only pass
workspaceDirwhen they already resolved it for the current run/tool.Verification
pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/agents/pi-embedded-runner/run.ts src/agents/pi-embedded-runner/compact.ts src/agents/btw.ts src/agents/btw.test.ts src/agents/tools/pdf-tool.ts src/agents/tools/pdf-tool.test.tspnpm test src/agents/btw.test.ts src/agents/tools/pdf-tool.test.ts src/agents/models-config.write-serialization.test.ts src/plugins/current-plugin-metadata-snapshot.test.tspnpm test src/agents/pi-embedded-runner/compact.hooks.test.ts src/agents/pi-embedded-runner/run.before-agent-reply-cron.test.tspnpm check:changedpassed:tbx_01kqtef6dp7ygbxbnexf721zg7pnpm check:changelog-attributionsRefs #77519
Refs #77532