Skip to content

fix: strip message wrapper in CLI session title generation#7996

Merged
DOsinga merged 4 commits intoblock:mainfrom
extrasmall0:fix/cli-session-title-wrapper
Mar 26, 2026
Merged

fix: strip message wrapper in CLI session title generation#7996
DOsinga merged 4 commits intoblock:mainfrom
extrasmall0:fix/cli-session-title-wrapper

Conversation

@extrasmall0
Copy link
Copy Markdown
Contributor

CLI providers (gemini-cli, claude_code, codex, cursor_agent) all generate session titles like ---BEGIN USER MESSAGES--- because generate_simple_session_description() grabs the first 4 words from the raw message — which includes the wrapper that generate_session_name() adds around the actual user content.

This strips the ---BEGIN USER MESSAGES--- / ---END USER MESSAGES--- markers before extracting words, so titles actually reflect what the user said.

Single-file change, pretty straightforward.

Closes #7990

generate_simple_session_description() was taking the first 4 words from the
raw user message, which includes the ---BEGIN USER MESSAGES--- wrapper added
by generate_session_name(). This caused all CLI provider sessions to be
titled "---BEGIN USER MESSAGES---" instead of something meaningful.

Strip the wrapper markers before extracting words so the title reflects
actual user content.

Closes block#7990

Signed-off-by: Extra Small <[email protected]>
@extrasmall0 extrasmall0 force-pushed the fix/cli-session-title-wrapper branch from 84b8ff6 to c863087 Compare March 19, 2026 19:22
// Strip the wrapper added by generate_session_name so we get
// the actual user content instead of "---BEGIN USER MESSAGES---".
let stripped = text
.strip_prefix("---BEGIN USER MESSAGES---")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems rather brittle - if we change the marker on the other side of this, it will break. at a minimum use constants, but it would be even better if there was just a flag on providers that tells them whether to use this stripped down algorithm or to do the full call and check that at the callers side.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good point, the string matching is fragile. let me refactor — I'll extract the markers into constants at minimum, and also look into whether we can avoid the wrapping altogether by the time it hits generate_simple_session_description.

@DOsinga DOsinga added the needs_human label to set when a robot looks at a PR and can't handle it label Mar 20, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65a5c3ffe1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +70 to +74
let desc: String = stripped
.split_whitespace()
.take(4)
.collect::<Vec<_>>()
.join(" ")
.join(" ");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Truncate stripped CLI session titles to the same 100-char limit

When the opening user prompt starts with a long unbroken token (JWT, pasted key, minified JSON, etc.), this now returns that token verbatim as the session title. Unlike the normal Provider::generate_session_name path in crates/goose/src/providers/base.rs:682-687, the CLI shortcut never runs safe_truncate(..., 100), so Session.name can grow arbitrarily large before it is persisted in sessions.name (crates/goose/src/session/session_manager.rs:562-565). Please cap or post-process the simple title here the same way as the main path.

Useful? React with 👍 / 👎.

@extrasmall0 extrasmall0 force-pushed the fix/cli-session-title-wrapper branch from 65a5c3f to 6b22628 Compare March 22, 2026 16:05
@extrasmall0
Copy link
Copy Markdown
Contributor Author

refactored — markers are now constants (SESSION_NAME_PREFIX / SESSION_NAME_SUFFIX). also looked into skipping the wrap entirely but that touches the provider trait boundary so keeping it scoped for now. lmk if this looks better

match the truncation limit from the full provider path so
titles stay bounded even with long single-token inputs.

Signed-off-by: Extra Small <[email protected]>
@DOsinga DOsinga added this pull request to the merge queue Mar 26, 2026
Merged via the queue into block:main with commit 65376e0 Mar 26, 2026
22 checks passed
michaelneale added a commit that referenced this pull request Mar 26, 2026
* main: (337 commits)
  fix: replace panics with user-friendly errors in CLI session builder (#7901)
  fix: read GOOSE_CONTEXT_LIMIT from config.yaml, not just env vars (#7900)
  fix: deliver truncation notice as separate content block (#7899)
  fix: use platform-appropriate commands in developer extension instructions (#7898)
  fix: replace any with proper SVG types in icon components (#7873)
  chore: remove debug console.log statements, stale comments, and dead code (#8142)
  feat: Gemini OAuth provider (#8129)
  chore(deps): bump picomatch from 2.3.1 to 2.3.2 in /documentation (#8123)
  feat: show installed skills in UI (#7910)
  fix(deps): gate keyring platform features behind target-specific deps (#8039)
  chore(deps): bump yaml from 2.8.2 to 2.8.3 in /evals/open-model-gym/suite (#8124)
  fix: strip message wrapper in CLI session title generation (#7996)
  fix(providers): fall back to configured models when models endpoint fetch fails (#7530)
  chore(deps): bump brace-expansion from 5.0.3 to 5.0.5 in /evals/open-model-gym/suite (#8139)
  fix: prevent Ollama provider from hanging on tool-calling requests (#7723)
  fix: VMware Tanzu Platform provider - bug fixes, streaming, UI improvements (#8126)
  feat: allow GOOSE_CLI_SHOW_THINKING to be set in config.yaml (#8097)
  fix: GitHub Copilot auth fails to open browser in Desktop app (#6957) (#8019)
  fix(ci): produce .tar.gz archives for Zed ACP registry compatibility (#8054)
  feat: add GOOSE_SHOW_FULL_OUTPUT config to disable tool output truncation (#7919)
  ...

# Conflicts:
#	crates/goose/src/providers/formats/openai.rs
hydrosquall pushed a commit to hydrosquall/goose that referenced this pull request Mar 31, 2026
blackgirlbytes pushed a commit that referenced this pull request Apr 2, 2026
* main: (337 commits)
  fix: replace panics with user-friendly errors in CLI session builder (#7901)
  fix: read GOOSE_CONTEXT_LIMIT from config.yaml, not just env vars (#7900)
  fix: deliver truncation notice as separate content block (#7899)
  fix: use platform-appropriate commands in developer extension instructions (#7898)
  fix: replace any with proper SVG types in icon components (#7873)
  chore: remove debug console.log statements, stale comments, and dead code (#8142)
  feat: Gemini OAuth provider (#8129)
  chore(deps): bump picomatch from 2.3.1 to 2.3.2 in /documentation (#8123)
  feat: show installed skills in UI (#7910)
  fix(deps): gate keyring platform features behind target-specific deps (#8039)
  chore(deps): bump yaml from 2.8.2 to 2.8.3 in /evals/open-model-gym/suite (#8124)
  fix: strip message wrapper in CLI session title generation (#7996)
  fix(providers): fall back to configured models when models endpoint fetch fails (#7530)
  chore(deps): bump brace-expansion from 5.0.3 to 5.0.5 in /evals/open-model-gym/suite (#8139)
  fix: prevent Ollama provider from hanging on tool-calling requests (#7723)
  fix: VMware Tanzu Platform provider - bug fixes, streaming, UI improvements (#8126)
  feat: allow GOOSE_CLI_SHOW_THINKING to be set in config.yaml (#8097)
  fix: GitHub Copilot auth fails to open browser in Desktop app (#6957) (#8019)
  fix(ci): produce .tar.gz archives for Zed ACP registry compatibility (#8054)
  feat: add GOOSE_SHOW_FULL_OUTPUT config to disable tool output truncation (#7919)
  ...

# Conflicts:
#	crates/goose/src/providers/formats/openai.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs_human label to set when a robot looks at a PR and can't handle it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI providers generate session titles from prompt wrapper instead of user content

2 participants