Skip to content

fix(gateway): honor selected model for worktree titles - #124902

Merged
steipete merged 5 commits into
mainfrom
steipete/create-time-title-model-routing-7471e0
Aug 17, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/create-time-title-model-routing-7471e0

Conversation

@steipete

@steipete steipete commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Related: #124787

What Problem This Solves

Fixes an issue where creating a managed-worktree session could generate its title and worktree name through the agent default route instead of the new session’s selected provider, model, runtime, and auth profile. This covered explicit models and registered session-catalog targets, and now also covers children that inherit their selection from a parent session.

Why This Change Was Made

One create-time selection resolver now handles default, explicit, catalog, and inherited-parent routes. Explicit and catalog routes retain the config-policy validation added by this PR. Parent inheritance is projected only inside the canonical session-creation owner, after that owner validates the parent, its ownership, and its model lock, then carries the narrow provider/model/runtime/profile selection into lifecycle preparation.

Title work still starts before repository resolution whenever the route is knowable at dispatch: default sessions without a parent, explicit models, and catalog targets. Parent-only requests defer title preparation until the validated inherited selection reaches the lifecycle callback. Denied or invalid direct selections continue to suppress title preparation entirely. The persisted create path remains the sole live model-catalog availability validator, so this does not restore the blocking catalog load removed by #122471.

User Impact

Create-time titles, managed-worktree branch names, persisted child selection, and the first chat turn now agree for default, explicit, catalog-backed, and parent-inherited sessions. A policy-rejected route cannot receive title content before the create request is rejected. Existing title persistence, timeout, and worktree fallback behavior is unchanged.

Evidence

  • Boundary regression: the new inherited-parent initial-message worktree case failed before the owner-boundary repair because the title generator received the agent default while the child persisted the parent selection. It now observes the inherited model reference, runtime, and preferred profile; the generated title names the branch and persists on the child; and the child entry carries the same inherited route.
  • Existing explicit-model, registered-catalog, default-route, and denied-model cases remain covered. The denied route still observes no title completion, worktree, or session row.
  • node scripts/run-vitest.mjs src/gateway/server.sessions.create.test.ts src/gateway/dashboard-session-title.test.ts src/gateway/server-methods/chat-send-command-replies.test.ts src/agents/worktrees/name.test.ts src/agents/worktrees/service.naming.test.ts — 148 tests passed across five files.
  • Blacksmith Testbox tbx_01m06nnsvarh61z99z2028s8dx: production types, all core test-type shards, and core oxlint passed. Run: https://github.com/openclaw/openclaw/actions/runs/31985343271
  • Targeted oxfmt, targeted local oxlint, git diff --check, and the final mandatory uncommitted autoreview passed with no accepted/actionable findings.
  • Production LOC: +126/-50 (net +76); tests: +207/-42 (net +165). The production growth is the canonical four-route selection projection plus the narrow lifecycle seam. The category helper is a pure extraction that keeps sessions-create.ts net -5 lines and under its max-lines budget without a suppression.
  • No separate visual capture: this changes routing for the existing title/worktree UI flow rather than its rendered appearance; the isolated dev-Gateway visual proof remains on fix(gateway): worktree names from generated session titles; start title work at dispatch #124787.
  • AI-assisted; maintainer reviewed and verified the final diff.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 16, 2026 23:16
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete steipete self-assigned this Aug 16, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 1:13 AM ET / 05:13 UTC.

ClawSweeper review

What this changes

Routes managed-worktree title generation through the session’s selected provider, model, runtime, and auth profile for default, explicit, catalog, and inherited-parent creation paths.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for normal maintainer review. Current main still starts worktree title generation without the selected session entry; the PR carries that route through the creation owner and adds focused coverage, with no blocking defect found. Its clean-but-behind branch needs merge-head validation.

Priority: P1
Reviewed head: 9339f282e05dc3cfede818fc902a4e346a8476a1

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is a well-covered owner-boundary repair, while direct after-fix live behavior evidence for this particular model-route change is limited.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: This maintainer-authored Gateway repair is not subject to the external-contributor proof gate; focused boundary coverage and exact-head CI are supporting evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored Gateway repair is not subject to the external-contributor proof gate; focused boundary coverage and exact-head CI are supporting evidence.
Evidence reviewed 6 items Current-main defect: Current main prestarts worktree title generation without an entry, while the title generator derives provider, model, runtime, and profile from that optional entry; selected routes therefore cannot reach this early title call.
Direct and catalog route repair: The PR computes a narrow title selection before repository resolution for known direct or catalog routes, suppressing title work when policy normalization rejects the selection.
Parent-boundary repair: The PR validates the parent in the session-creation owner, then forwards only the inherited selection into lifecycle preparation before worktree provisioning; persistence uses the same inheritance projection later in the create transaction.
Findings None None.
Security None None.

How this fits together

Gateway session creation selects a model route, optionally creates a managed worktree, and starts a title from the first message. The route used for title generation must agree with the stored session and its first chat turn.

flowchart LR
  A[Session creation request] --> B[Resolve selected model route]
  B --> C[Prepare title generation]
  C --> D[Create worktree]
  D --> E[Persist session selection]
  E --> F[Dispatch first chat turn]
Loading

Before merge

  • Resolve merge risk (P1) - The PR changes which auth profile and runtime are used before session persistence; merge validation should preserve the policy-denial and inherited-parent cases on the actual merge head.
  • Resolve merge risk (P1) - Production code grows by 76 net lines for a bug fix; the added pre-persistence selection projection is justified only if it remains the single owner-boundary path after the branch is refreshed against current main.
  • Resolve merge risk (P1) - GitHub reports the PR clean but behind current main, so the focused route table should be rerun on the merge head before landing.
  • Complete next step (P2) - This assigned maintainer PR has no discrete automated repair finding; the remaining action is normal merge-head validation and maintainer review.
Agent review details

Security

None.

PR surface

Source +76, Tests +165. Total +241 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 5 126 50 +76
Tests 1 208 43 +165
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 334 93 +241

Review metrics

Metric Value Why it matters
Production versus regression coverage production +76 net; tests +165 net The production growth implements a four-route selection projection before persistence, while the added coverage exercises those routes plus policy denial.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/server-methods/session-create-category.ts, serialized state: src/gateway/server-methods/sessions-create.ts, serialized state: src/gateway/session-create-service.ts, serialized state: src/gateway/session-lifecycle-preparation.ts, unknown-data-model-change: src/gateway/server-methods/sessions-create.ts, unknown-data-model-change: src/gateway/session-create-service.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Validate selected credentials on the merge head (recommended)
    Refresh against current main and rerun the focused session-creation route table so the pre-persistence title request uses the same allowed profile and runtime as the stored child.

Technical review

Best possible solution:

Keep one validated selection projection in the session-creation owner, start direct titles from it, defer inherited titles until parent validation, and validate that route table on the final merge head.

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

Yes—current main’s early title call omits the session entry, while the title helper resolves its route from that entry. The PR’s focused boundary test describes the failing explicit, catalog, and inherited routes, although this read-only review did not execute it.

Is this the best way to solve the issue?

Yes, with merge-head validation. Carrying a narrow validated selection through the existing creation and lifecycle owners avoids both a downstream workaround and restoration of a blocking live-catalog load.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d0b1b6d0ec3e.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: A managed-worktree session can use a default model route for title generation despite an explicitly selected or inherited model route.
  • merge-risk: 🚨 auth-provider: The PR intentionally propagates the selected auth profile and runtime into a pre-persistence model call, so merge-head validation must keep it aligned with policy and persisted selection.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored Gateway repair is not subject to the external-contributor proof gate; focused boundary coverage and exact-head CI are supporting evidence.

Evidence

What I checked:

Likely related people:

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rerun the focused route table against the final merge head and attach the resulting exact-head validation.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-16T23:24:16.906Z sha f583f6a :: found issues before merge. :: [P1] Validate the title route before starting the completion
  • reviewed 2026-08-17T00:41:21.263Z sha e9816d9 :: found issues before merge. :: [P1] Route inherited worktree titles through the inherited selection
  • reviewed 2026-08-17T01:02:34.091Z sha 66d6e62 :: found issues before merge. :: [P1] Carry inherited parent selection into the title entry
  • reviewed 2026-08-17T01:10:21.271Z sha 66d6e62 :: found issues before merge. :: [P1] Route inherited parent selection before starting the title
  • reviewed 2026-08-17T02:23:14.576Z sha cd67c244f2f6993430bf48b93675e8ad4b031151 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T03:26:47.741Z sha 20d4036e15422eac962691a22252ed905a1518ef :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T04:46:10.949Z sha 9339f28 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T04:56:32.156Z sha 9339f28 :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The inherited-parent route now comes from the canonical parent-validation owner and has boundary coverage for title routing, branch naming, title persistence, and child selection. Exact-head focused, type, test-type, lint, and autoreview proof is recorded in the updated PR body.

@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Exact-head source update: preserve normalized category registration after the helper extraction and cover surrounding whitespace in the existing category test. Reviewed head: 20d4036e15422eac962691a22252ed905a1518ef.

@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Carry the create request’s explicit or catalog-backed provider, model, runtime, and auth profile into create-time title routing without blocking on model-catalog loading.

Related: #124787
Reuse the canonical model-policy resolver before prestarting title generation. Denied or invalid selections now skip title completion while persisted creation remains the sole live-catalog availability validator.
Preserve the null suppression sentinel at the preparation boundary while forwarding only the title generator’s optional entry shape.
Keep post-commit category registration aligned with the normalized category persisted by session creation after the helper extraction.
@steipete steipete closed this Aug 17, 2026
@steipete steipete reopened this Aug 17, 2026
@steipete
steipete force-pushed the steipete/create-time-title-model-routing-7471e0 branch from 20d4036 to 9339f28 Compare August 17, 2026 04:39
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Aug 17, 2026
@steipete steipete closed this Aug 17, 2026
@steipete steipete reopened this Aug 17, 2026
@steipete steipete closed this Aug 17, 2026
@steipete steipete reopened this Aug 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for source head 9339f282e05dc3cfede818fc902a4e346a8476a1.

Root cause: managed-worktree title generation started before the new session entry existed, so it could fall back to the agent default instead of the provider/model/profile selection already validated for the session. The canonical fix resolves that selection once in the session-creation owner and carries it through title generation, worktree naming, persistence, and the first chat turn. It does not add a blocking loadGatewayModelCatalog call before lifecycle preparation.

Coverage proves the default, explicit, catalog-backed, inherited-parent, and policy-denied selection paths. The denied path creates no title worktree or session row. The extracted post-create category registration also preserves the normalized category value. Presentation itself is unchanged; the related visual behavior is covered by #124787.

Production LOC: +126/-50 (net +76) | Tests: +208/-43 (net +165). The mechanical rebase preserved the stable patch identity and the same six-file diff.

Proof:

No docs, changelog, config, protocol, SQLite, dependency, or release changes are involved.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 17, 2026
@steipete
steipete merged commit b2709ce into main Aug 17, 2026
790 of 796 checks passed
@steipete
steipete deleted the steipete/create-time-title-model-routing-7471e0 branch August 17, 2026 05:37
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
* fix(gateway): honor selected model for worktree titles

Carry the create request’s explicit or catalog-backed provider, model, runtime, and auth profile into create-time title routing without blocking on model-catalog loading.

Related: openclaw#124787

* fix(gateway): validate worktree title route

Reuse the canonical model-policy resolver before prestarting title generation. Denied or invalid selections now skip title completion while persisted creation remains the sole live-catalog availability validator.

* fix(gateway): normalize denied title selection

Preserve the null suppression sentinel at the preparation boundary while forwarding only the title generator’s optional entry shape.

* fix(gateway): inherit worktree title route

* fix(gateway): preserve normalized session categories

Keep post-commit category registration aligned with the normalized category persisted by session creation after the helper extraction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant