Skip to content

refactor(ai): Adopt whilesmartgo/agents for the model engine#183

Merged
nfebe merged 1 commit into
mainfrom
feat/adopt-agents-engine
Jul 19, 2026
Merged

refactor(ai): Adopt whilesmartgo/agents for the model engine#183
nfebe merged 1 commit into
mainfrom
feat/adopt-agents-engine

Conversation

@nfebe

@nfebe nfebe commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

First step of #182. The assistant's OpenAI-compatible model client was a bespoke copy of the chat-completions wire format; it now delegates to github.com/whilesmartgo/agents (the core extracted from this same code), so the engine is reused instead of maintained twice. Net -84 lines here, and the shared library is now a direct dependency.

Behaviour is unchanged: the existing provider tests (completion, tool calling, keyless, error mapping) pass without edits, which is the point of keeping FlatRun's Provider/Request/Response types and mapping across the boundary.

Still on #182, as follow-ups: expressing the built-in tools as agents.Tool values and driving the session loop through agents.Runner. Those are held back because FlatRun's stored message carries UI-only fields (display, hidden) the library's minimal message does not, so deeper adoption wants either a library message-metadata field or a session-model change.

The assistant's OpenAI-compatible model client was a bespoke copy of the
chat-completions wire format. It now comes from the shared whilesmartgo/agents
library, so the same engine is reused rather than maintained in two places.
Behaviour is unchanged: the existing provider tests pass as-is.

This is the engine-layer step of adopting the extracted agent core; expressing
the tools and the tool loop through the library's Registry and Runner follows.
@sourceant

sourceant Bot commented Jul 19, 2026

Copy link
Copy Markdown

Code Review Summary

This PR refactors the OpenAI-compatible model engine to utilize the github.com/whilesmartgo/agents library. This change replaces bespoke HTTP and JSON handling with a shared engine while maintaining the existing Provider interface.

🚀 Key Improvements

  • Reduced code complexity by delegating OpenAI wire-format handling to a library.
  • Implemented a clean adapter layer to map internal Request and Response types.
  • Maintained support for custom base URLs, timeouts, and API keys.

@sourceant sourceant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review complete. No specific code suggestions were generated. See the overview comment for a summary.

@nfebe
nfebe merged commit 9474b76 into main Jul 19, 2026
6 checks passed
@nfebe
nfebe deleted the feat/adopt-agents-engine branch July 19, 2026 19:37
@nfebe nfebe mentioned this pull request Jul 20, 2026
42 tasks
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.

1 participant