Skip to content

fix(prompt): render reasoning effort next to model in CLI prompt#3101

Merged
amitksingh1490 merged 3 commits intotailcallhq:mainfrom
EmojiPati:feat/prompt-reasoning-effort
Apr 26, 2026
Merged

fix(prompt): render reasoning effort next to model in CLI prompt#3101
amitksingh1490 merged 3 commits intotailcallhq:mainfrom
EmojiPati:feat/prompt-reasoning-effort

Conversation

@EmojiPati
Copy link
Copy Markdown
Contributor

Summary

Surface the currently configured reasoning effort (e.g. `HIGH`, `MEDIUM`) in the `forge` CLI's own right prompt, matching the zsh rprompt behavior introduced in #3087. Users now see the configured effort regardless of whether forge is invoked through the zsh plugin or directly.

Context

#3087 added reasoning effort to `ZshRPrompt` (`crates/forge_main/src/zsh/rprompt.rs:33`), which renders the `RPROMPT` for users who have the zsh plugin installed. The `forge` CLI's interactive reedline prompt — `ForgePrompt` at `crates/forge_main/src/prompt.rs:35` — renders agent, tokens, cost, and model but was never updated with the same effort segment. So users running `forge` without the zsh plugin (or in CI, via `-p`, etc.) couldn't see it.

Changes

  • `crates/forge_main/src/prompt.rs`
    • Adds `reasoning_effort: Option` to `ForgePrompt` and imports `forge_api::Effort`.
    • `render_prompt_right` appends the effort after the model segment using the same rules as the zsh rprompt: `Effort::None` suppressed, `Color::Yellow` when active (tokens > 0) and `Color::DarkGray` otherwise, and the label collapses to its first three characters on terminals narrower than `WIDE_TERMINAL_THRESHOLD` (100 columns).
    • Helpers `term_width()` and `effort_label(effort, width)` isolate the formatting logic.
  • `crates/forge_main/src/ui.rs`
    • `prompt()` resolves the effort via `ForgeAPI::get_reasoning_effort` and forwards it to `ForgePrompt` before each reedline prompt cycle.
    • `ForgeConfig`'s env-var source (`crates/forge_config/src/reader.rs`) already resolves `FORGE_REASONING__EFFORT`, so per-session overrides set by the zsh plugin (`shell-plugin/forge.theme.zsh`) are picked up automatically.

Rendered Examples

Terminal width Effort Tokens Output
Wide (≥100) `Effort::High` >0 ` FORGE 1.5k gpt-4 HIGH` (yellow)
Narrow (<100) `Effort::Medium` 0 ` FORGE gpt-4 MED` (dim)
Any `Effort::None` / unset ` FORGE gpt-4` (unchanged)

Testing

```bash
cargo test -p forge_main --lib prompt::
cargo test -p forge_main --lib
cargo clippy -p forge_main --lib --tests -- -D warnings
```

Three new unit tests in `prompt.rs`:

  • `test_render_prompt_right_with_reasoning_effort` — effort renders after the model segment
  • `test_render_prompt_right_hides_effort_none` — `Effort::None` is suppressed (regression guard)
  • `test_effort_label_narrow_vs_wide` — width-aware label (`MED` vs `MEDIUM`)

Links

@github-actions github-actions Bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 21, 2026
@EmojiPati EmojiPati force-pushed the feat/prompt-reasoning-effort branch from 79e4937 to e91456f Compare April 21, 2026 09:16
@amitksingh1490 amitksingh1490 merged commit 6f10f4b into tailcallhq:main Apr 26, 2026
8 checks passed
@amitksingh1490 amitksingh1490 changed the title feat(prompt): render reasoning effort next to model in CLI prompt fix(prompt): render reasoning effort next to model in CLI prompt Apr 26, 2026
@amitksingh1490 amitksingh1490 added type: fix Iterations on existing features or infrastructure. and removed type: feature Brand new functionality, features, pages, workflows, endpoints, etc. labels Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants