Feat: agent loop for openai compatible LLMs#241
Open
valdis wants to merge 10 commits into
Open
Conversation
Adds ConfigurableAgentAdapter backed by @eggai/configurable-agent, routing the openai-compatible provider through the Vercel AI SDK v5 agent loop. - Add openai-compatible to provider enum and adapter type mapping - Add ConfigurableAgentAdapter: converts qualops ToolDefinitions to AI SDK ToolSet using inputSchema + jsonSchema() wrapper (Zod v4 → JSON Schema) - Wire baseUrl/apiKey from stage config through to the agent - Restore per-provider adapter routing (anthropic/openai unchanged) - Add adapter selection unit tests - Add .qualopsrc.configurable-agent-test.json for manual testing
Two issues from code review: 1. Delete resolveProvider() from ConfigurableAgentAdapter — the function was dead code (claude/openai branches unreachable since the adapter is only ever instantiated for openai-compatible) and a drift risk. Hardcode 'openai-compatible' as the library provider. 2. Declare baseUrl and apiKey in aiStageConfigSchema with env-var fallbacks (OPENAI_BASE_URL / OPENAI_API_KEY) resolved in getResolvedStageConfig, matching the pattern used by other providers. Remove the as string | undefined casts in the executor that suppressed missing type declarations.
Tool call visibility was driven from inside each tool's execute function, which fires after the model request is already in flight. Move it to the tool_call event handler to match the pattern used by AnthropicAdapter and OpenAIAdapter — fires when the model requests the tool, before execution.
…ter system prompt The configurable-agent loop is a single flat agent with no subagent concept. Previously it ignored params.agents entirely, so the model received only the bare orchestrator system prompt with no tool-use instructions, causing it to finish in one step without calling any tools. Flatten all enabled subagent prompts into the system prompt under "## Review perspectives", and append an "## Available tools" section listing the tool names so the model knows what investigative tools it has access to.
The hardcoded "Use Grep/Glob ONLY if checking external dependencies" and "Max 10 tool calls" boilerplate was contradicting the subagent prompts that the ConfigurableAgentAdapter injects — causing the model to finish in one step with no tool calls. buildSystemPrompt now returns only user-configured content (systemPrompt + prompt file). The adapter is responsible for composing the full system prompt with subagent instructions and available tools.
…down aliases Subagent prompts reference SDK aliases (Read, Grep, Glob) that don't match the actual registered tool names (read_file, grep_files, glob_files). List tools as a bulleted list with an explicit instruction to use exact names.
…prompt The framework-detector defaulted every file to 'typescript' regardless of actual language. The file extension in the path already signals the language to the model, so the label adds noise without value.
…d failures - Map rate_limit_tokens to a thrown error with an actionable message - Map stream_error to warning with partial response recovery - Warn when output exists but yields no parseable issues (truncation hint)
…error handling Replace the switch statement in ConfigurableAgentAdapter with a lookup map (ERROR_SUBTYPE_MAP) so new error codes can be added in one line. Unknown codes throw immediately rather than silently swallowing. Replace the single error_rate_limit_tokens check in AgenticExecutor with a HARD_FAILURES set that also covers error_max_tokens (max output tokens reached). Add max_tokens_reached to the error subtype map so finishReason =length is surfaced as a hard failure with partial content recovery.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.