Skip to content

refactor: remove duplication in model resolution, thinking budget, and message construction#2038

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/you-are-the-master-decoupler-you-know-ev-e75a9547
Mar 10, 2026
Merged

refactor: remove duplication in model resolution, thinking budget, and message construction#2038
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/you-are-the-master-decoupler-you-know-ev-e75a9547

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Mar 10, 2026

Summary

Four focused deduplication changes that remove ~60 lines of repeated code without changing behavior.

Changes

  • NewAgentMessage(string) — accepts a plain string instead of *agent.Agent since only the name was used. Simplifies tests and reduces coupling between session and agent packages.

  • ThinkingBudget.IsDisabled() — replaces two divergent copies of isThinkingBudgetDisabled (in provider.go and teamloader.go) with a single method on the type itself.

  • resolveModelRefs — deduplicates createProvidersFromInlineAlloy and createProvidersFromAlloyConfig which had identical loop bodies, then inlines the trivial wrappers at their two call sites.

  • ParseModelRef — extracts the strings.Cut(ref, "/") + validation + ModelConfig construction pattern that was repeated in six places across teamloader, model_switcher, provider routing, config overrides, evaluation, and YAML unmarshaling.

Assisted-By: docker-agent

@dgageot dgageot requested a review from a team as a code owner March 10, 2026 15:27
rumpl
rumpl previously approved these changes Mar 10, 2026
@docker-agent
Copy link

docker-agent bot commented Mar 10, 2026

PR Review Failed — The review agent encountered an error and could not complete the review. View logs.

@dgageot dgageot force-pushed the board/you-are-the-master-decoupler-you-know-ev-e75a9547 branch from 20f85e0 to 8e50290 Compare March 10, 2026 16:14
…d message construction

- NewAgentMessage takes a plain string instead of *agent.Agent since
  only the name was used.

- Replace duplicated isThinkingBudgetDisabled functions in provider.go
  and teamloader.go with a single ThinkingBudget.IsDisabled() method.

- Extract resolveModelRefs to deduplicate createProvidersFromInlineAlloy
  and createProvidersFromAlloyConfig, then inline the trivial wrappers.

- Extract ParseModelRef for the strings.Cut(ref, "/") + ModelConfig
  construction pattern repeated in six call sites.

Assisted-By: docker-agent
@dgageot dgageot force-pushed the board/you-are-the-master-decoupler-you-know-ev-e75a9547 branch from 8e50290 to 6930817 Compare March 10, 2026 17:37
@dgageot dgageot changed the title refactor: decouple session, agent, and model resolution refactor: remove duplication in model resolution, thinking budget, and message construction Mar 10, 2026
@dgageot dgageot merged commit c206962 into docker:main Mar 10, 2026
5 checks passed
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.

3 participants