Repository navigation
Align ACP session model config - #1625
BlueHotDog wants to merge 5 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
frontman/libs/client/src/state/Client__State__StateReducer.res
Lines 1864 to 1866 in 4d76b41
When the user changes the model dropdown, this action updates only reducer state and local storage; there is no caller for the newly added session/set_config_option handler anywhere in the client. Consequently, tasks.current_model remains unchanged until a prompt is submitted, so switching tasks or reloading before sending a prompt causes session/load to restore the old model and discard the selection. Dispatch an effect that invokes the active session's config-option RPC and reconciles its response.
AGENTS.md reference: AGENTS.md:L197-L233
ℹ️ 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".
| ACP.build_config_option_update_notification(socket.assigns.task_id, config_options) | ||
| ) | ||
|
|
||
| {:noreply, socket} |
There was a problem hiding this comment.
Synchronize the session model after provider changes
When credentials or a custom provider backing current_model are removed, current_config_options/2 advertises a fallback model, but this handler returns the socket unchanged and leaves the stale model in the task row. A generic ACP client that subsequently omits _meta.model—the flow this commit adds support for—therefore executes with the removed model via current_model/1, even after reconnecting because the stale row is loaded again. Update both the socket assign and persisted task to the advertised fallback, or clear them when no models remain.
Useful? React with 👍 / 👎.
| case current_config_value(values, current_value) do | ||
| nil -> | ||
| [] |
There was a problem hiding this comment.
Deliver an explicit empty config list to the client
When a user has no configured models, this now returns [], which put_config_options/2 converts into an omitted configOptions field in both session/new and session/load. The client dispatches ConfigOptionsReceived only for Some(configOptions), so it never clears a model restored from local storage and leaves configOptions as None; in turn, providerSetupRequired remains false and the stale model can keep the prompt UI enabled for a session that has no usable provider. Include configOptions: [] in session results or otherwise explicitly clear the client state for this case.
Useful? React with 👍 / 👎.
| defp selected_model(socket, %{"model" => model_ref}) do | ||
| case parse_client_model(model_ref) do | ||
| {:ok, model} -> {:ok, model} | ||
| :error -> current_model(socket) | ||
| end |
There was a problem hiding this comment.
Reject invalid explicit model values
When a prompt explicitly contains a malformed model value, this branch silently falls back to the persisted session model and accepts the prompt. That makes a typo or malformed structured value run against a different model than the client requested, whereas only an absent model should use the agent-owned default; return :error when the key is present but cannot be parsed so the request receives an invalid-params response.
AGENTS.md reference: AGENTS.md:L106-L115
Useful? React with 👍 / 👎.
| with {:ok, agent_id} <- | ||
| Agents.resolve_agent_id(scope, meta["agent"] || Agents.default_agent_id(scope)), | ||
| {:ok, _task} <- Tasks.set_current_model(scope, task_id, model), | ||
| {:ok, _row} <- |
There was a problem hiding this comment.
Update the model only after accepting the prompt
The task's current model is persisted before submit_user_message/2 validates the selected skill, content blocks, and message ID. If any of those validations fail—for example, a duplicate message ID paired with a different model—the request returns an error but the database still records the new model, while the socket retains the old one because its assign occurs only on success. Move the update after successful submission or make both writes atomic so rejected prompts cannot mutate session configuration.
Useful? React with 👍 / 👎.
|
|
||
| def change do | ||
| alter table(:tasks) do | ||
| add(:current_model, :string) |
There was a problem hiding this comment.
Store current model references in an unbounded text column
PostgreSQL maps this migration's :string to a 255-character varchar, but custom providers permit 256-character model IDs and serialize them as custom:<36-character UUID>:<model ID>, producing references up to roughly 300 characters. Selecting or prompting with any otherwise-valid custom model ID longer than about 211 characters will therefore fail when set_current_model/3 writes this column. Use :text or constrain the complete serialized reference to the database limit.
Useful? React with 👍 / 👎.
| "id" => "model", | ||
| "name" => "Model", | ||
| "category" => "model", | ||
| "currentValue" => selected_value, |
There was a problem hiding this comment.
Preserve session selection during global config refreshes
On a provider configuration change, both TasksChannel and TaskChannel receive the same PubSub event. The global tasks channel calls build_model_config_options/1 without a session value, so this field identifies the first available model as current, while the task channel independently sends the task's actual persisted value; because those pushes originate from separate channel processes, their delivery order is not guaranteed. If the global update arrives last, ConfigOptionsReceived silently switches the UI and next prompt to the first model rather than the session's model. Global catalog refreshes must not overwrite active session state, or the client must preserve/reconcile the session-specific value.
Useful? React with 👍 / 👎.
4d76b41 to
02c0a6b
Compare
cc5393e to
65173b4
Compare
Summary
session/set_config_optionand restore session state on task activation.currentValuein config options. Send the global model catalog separately, in a map-shaped WebSocket payload, so catalog refreshes cannot overwrite session selection.session/newwithout a model preference. Create an unselected session without choosing a default, then reject prompts until a valid model is selected.textcolumn.main, retaining its connection lifecycle, billing allowances, activation tracking, preview behavior, and current model catalog.Fixes #1289
Validation
Passed locally on the updated branch:
make rescript-buildmake -C libs/client test— 496 testsmake -C libs/frontman-client test— 108 testsmake -C libs/frontman-protocol test— 33 testsmake -C libs/client test-screenshots— 70 Chromium testsmake -C libs/frontman-protocol check-schemasmake reanalyzeand all nine library checks in the pre-push hook — zero issuescd apps/frontman_server && DB_NAME=frontman_pr1625_validation_v2 make precommit— compile with warnings as errors, format, Credo, and 1,099 testsgit diff --checkmake e2ecould not run locally becausetest/e2e/.envis absent. The fresh GitHub E2E run must verify the complete authenticated AI workflow.Regression coverage