Skip to content

Conversation

@jackjackbits
Copy link
Contributor

@jackjackbits jackjackbits commented Jun 17, 2025

Summary

This PR implements a comprehensive feature for configuring and monitoring different AI models for planning (lead) and execution (worker) phases in the Goose GUI, with real-time display of the currently active model.

Changes

Backend Enhancements

  • Event System: Added AgentEvent::ModelChange event type to track when the system switches between models
  • API Endpoint: Implemented /config/current-model endpoint to retrieve the active model information
  • Provider Integration: Enhanced LeadWorkerProvider with get_active_model() method for accurate model state tracking
  • Global State Management: Fixed async runtime panic by implementing global state store for model information
  • Cross-Component Integration: Integrated ModelChange events across all components (CLI, web, FFI, scheduler)

Frontend Improvements

  • Configuration UI: Created LeadWorkerSettings component with intuitive interface for model configuration
  • Real-time Display: Shows currently active model with mode indicators (e.g., "claude-opus (lead)", "gpt-4o (worker)")
  • State Management: Migrated from window.appConfig to React Context for better state management
  • Event-Driven Updates: Implemented automatic UI updates when models switch, no polling required

Configuration Options

Users can now configure:

  • Lead model selection with provider choice
  • Worker model selection with provider choice
  • Lead turns (number of planning iterations)
  • Failure thresholds for fallback behavior
  • Toggle to enable/disable lead-worker mode entirely

Technical Details

The main challenge was displaying the correct active model during execution. This was solved by:

  1. Using the usage.model field from provider responses for accurate model identification
  2. Creating a React Context (ModelContext) for shared model state across components
  3. Implementing a priority system where active model from events takes precedence over configured model

Testing

  • All existing tests pass, including agent tests that were updated for the new event type
  • Manual testing confirms real-time model display updates correctly
  • Code has been formatted with cargo fmt and passes cargo clippy -- -D warnings
  • Frontend code passes lint checks

Screenshots

Screenshot 2025-06-17 at 15 37 55

The new UI allows users to:

  1. Enable/disable lead-worker mode
  2. Select different models and providers for lead and worker roles
  3. Configure advanced parameters
  4. See real-time model usage in the chat interface

Files changed: 16
Insertions: 475
Deletions: 9

## Summary
Implements real-time model display updates in the GUI when using lead-worker mode, showing which model (lead or worker) is currently active.

## Changes

### Backend
- Add ModelChange event type to AgentEvent enum for tracking model switches
- Emit ModelChange events when the lead-worker provider switches between models
- Add /config/current-model API endpoint to fetch the currently active model
- Update global current model store when providers complete requests
- Fix runtime panic by avoiding block_on in async context (use global store instead)

### Frontend
- Create LeadWorkerSettings UI component for configuring lead-worker mode
- Add fields for lead model, worker model, lead turns, failure threshold, and fallback turns
- Update useMessageStream hook to capture ModelChange events from SSE stream
- Use React Context to share current model info instead of window.appConfig (which is read-only)
- Update ModelsBottomBar to display active model with mode indicator (lead/worker)
- Prioritize active model display when lead-worker mode is enabled

### Event Handling
- Handle ModelChange events in all AgentEvent match statements:
  - CLI session handler
  - Web command handler
  - FFI library
  - Scheduler
  - Scheduler executor
  - Agent tests

## Testing
- Fixed agent tests to handle the new ModelChange event
- All tests pass
- Clippy checks pass
- Frontend linting and type checking pass
Copy link

@LuismiLabs LuismiLabs left a comment

Choose a reason for hiding this comment

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

We may want to the newlines at end of files in order to follow code standards, I just added in one place but for readability its nice to have, not a blocker

</div>
</div>
);
} No newline at end of file

Choose a reason for hiding this comment

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

We may want to add this newline at end of file in order to follow code standards

@block block deleted a comment from joanna2028 Jun 17, 2025
@block block deleted a comment from joanna2028 Jun 17, 2025
@block block deleted a comment from joanna2028 Jun 17, 2025
@baxen
Copy link
Collaborator

baxen commented Jun 17, 2025

Thanks @joanna2028 for your interest in goose! We'll try to keep the discussion here scoped to the code and probably prefer X for other topics

@angiejones angiejones requested a review from michaelneale June 17, 2025 22:38
Copy link
Collaborator

@michaelneale michaelneale left a comment

Choose a reason for hiding this comment

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

LGTM, a nice addition to lead/worker. The CI failure should be resolved on main now (apparently a dependabot update gone wrong)

…ackjackbits/goose into jackjackbits-feature/gui-lead-worker-model-selector

* 'feature/gui-lead-worker-model-selector' of github.com:jackjackbits/goose:
  feat: Add real-time model display updates for lead-worker mode
@michaelneale
Copy link
Collaborator

updating it 🤞 that fixes the temporal build quirk

@michaelneale
Copy link
Collaborator

also don't worry about the apparent "extra" changes (which are already on main) its a forever github bug with showing synced fork diffs (will see if can get rid of it, but they aren't actual changes as already on main upstream/origin!)

@michaelneale michaelneale changed the base branch from main to micn/main June 18, 2025 03:20
@michaelneale michaelneale changed the base branch from micn/main to main June 18, 2025 03:20
@michaelneale
Copy link
Collaborator

ok - nice clean history now phew. Need to teach goose how to work around this 8 year old github bug

Copy link
Collaborator

@baxen baxen left a comment

Choose a reason for hiding this comment

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

Looks good!

In testing this, realized there is an unrelated issue where the model returned in usage does not exactly match the names in config (the providers use a more specific versioned result) - that makes the logic here yield some unknowns. However that's a separate PR - cc: @michaelneale

@baxen baxen merged commit 657718d into block:main Jun 18, 2025
7 checks passed
laanak08 added a commit that referenced this pull request Jun 18, 2025
* main: (28 commits)
  feat: optional fast edit models (#2580)
  feat: Add lead-worker model selection and real-time model display in GUI (#2964)
  chore(release): release version 1.0.29 (#2978)
  [fix][small] Replaced goose prompt unicode quotations with ascii quotations (#2972)
  fix: goose recipe prompt is not shown again when switch the view from settings to chat (#2870)
  fix: remove computer controller presentation (#2956)
  Fix GitHub Copilot Provider Config (#2955)
  Blog: Why I Used Goose to Build a Chaotic Emotion Detection App (#2959)
  Docs: Recipe settings (#2970)
  feat(ui): Add confirmation dialog for unsaved changes in extension modal (#2971)
  feat: alphabetize extensions in goose CLI (#2966)
  switch roles on condition for windows (#2975)
  fix version param for canary (#2974)
  enabling windows builds with code signing (#2968)
  feat(cli): add system prompt parameter to run command (#2253)
  Fix window not showing for some users (#2967)
  Add documentation for running with Ramalama local model serving in OCI Containers (#1973)
  Reddit MCP Server Tutorial (#2949)
  [fix] goose not quitting app completely (#2950)
  Opopadich/issue 1625 (#2904)
  ...
@QBlockQ
Copy link

QBlockQ commented Jun 18, 2025

The event-driven model sync, global state refactor, and React Context integration show sharp architectural thinking. Real-time clarity in lead-worker dynamics delivers true operational confidence. Solid execution!

lifeizhou-ap added a commit that referenced this pull request Jun 20, 2025
* main:
  Blog: Add video to container use blog (#3008)
  Use official logo in Goose web (#3012)
  fix shims for extensions on windows (#3009)
  fix powershell executions (#3006)
  Docs linux desktop (#3007)
  Platform Tool for Scheduler: Allow Goose to Manage Its Own Schedule (#2944)
  docs: container use blog and guide (#2962)
  Fix: Workflow syntax (#3002)
  Added just lint-ui for linting front end code (#2997)
  fix typo in secret name (#2994)
  feat(ui): add chain-of-thought panel above assistant messages (#2899)
  feat(cli): Add `--quiet /-q` flag to goose run (#2939)
  Feat: Recipe Library (#2946)
  Docs: Goose on Windows Installation (#2990)
  Fixes : Workflow error on issue comment (#2958)
  Add a setting for the quit confirmation dialog (#2901)
  Update bundle-desktop-windows.yml (#2988)
  feat: optional fast edit models (#2580)
  feat: Add lead-worker model selection and real-time model display in GUI (#2964)
btdeviant pushed a commit to btdeviant/goose that referenced this pull request Jun 25, 2025
s-soroosh pushed a commit to s-soroosh/goose that referenced this pull request Jul 18, 2025
cbruyndoncx pushed a commit to cbruyndoncx/goose that referenced this pull request Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants