Skip to content

Feat: agent loop for openai compatible LLMs#241

Open
valdis wants to merge 10 commits into
mainfrom
feat-agent-loop
Open

Feat: agent loop for openai compatible LLMs#241
valdis wants to merge 10 commits into
mainfrom
feat-agent-loop

Conversation

@valdis

@valdis valdis commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

valdis added 10 commits June 11, 2026 20:03
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.
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