Skip to content

PEN-128: add daemon OpenAI-compatible adapter#83

Open
wauputr4 wants to merge 2 commits into
mainfrom
agent/dimas/d0bb89de
Open

PEN-128: add daemon OpenAI-compatible adapter#83
wauputr4 wants to merge 2 commits into
mainfrom
agent/dimas/d0bb89de

Conversation

@wauputr4

Copy link
Copy Markdown
Member

Summary

Closes PEN-128.
Related to #69.

  • Reuses the shared OpenAI-compatible provider client from mizan-daemon so daemon dispatch normalizes chat completions and usage the same way as route-backed providers.
  • Adds optional daemon local_provider_api_key support while allowing no-auth local model servers.
  • Adds daemon smoke-style test coverage with a mock OpenAI-compatible upstream and documents the optional config field.

Validation

  • git diff --check
  • Not run: cargo fmt --check / cargo test -p mizan-providers -p mizan-daemon because cargo, rustc, and rustfmt are not installed in this runtime.

Co-authored-by: multica-agent <github@multica.ai>

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the daemon to use the shared OpenAiCompatibleProvider from mizan-providers instead of a manual implementation, and adds support for an optional local_provider_api_key configuration. Feedback highlights a critical issue where the switch to the new provider removed the request timeout, potentially allowing a hung local provider to block the entire daemon; wrapping the call in a 30-second timeout is recommended.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/mizan-daemon/src/main.rs Outdated
);

parse_chat_completion_response(&body, request.model.clone())
provider.chat_completions(&context, job.request.clone()).await

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Missing Request Timeout

Previously, call_local_provider used a reqwest::Client configured with a 30-second timeout. With the switch to OpenAiCompatibleProvider, it now uses a static reqwest::Client with no timeout configured.

Since the daemon runs sequentially in a single-task loop (handling heartbeats and job execution in the same loop), a hung or extremely slow local provider request will block the entire daemon. This stops heartbeats from being sent and prevents any new jobs from being processed.

Wrapping the provider call in a tokio::time::timeout restores the 30-second timeout safety net.

    timeout(
        Duration::from_secs(30),
        provider.chat_completions(&context, job.request.clone()),
    )
    .await
    .map_err(|_| AppError::infrastructure("local provider request timed out"))?

Co-authored-by: multica-agent <github@multica.ai>
@wauputr4 wauputr4 marked this pull request as ready for review June 14, 2026 05:07
@wauputr4

Copy link
Copy Markdown
Member Author

Addressed the daemon provider timeout review by wrapping the local OpenAI-compatible provider call in a 30s timeout. Also fixed the formatting diff that broke the previous Rust CI run; latest Rust CI is green.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a947574e9c

ℹ️ 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".

[dependencies]
clap = { version = "4", features = ["derive"] }
mizan-core = { path = "../mizan-core" }
mizan-providers = { path = "../mizan-providers" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Regenerate Cargo.lock for the daemon dependency changes

Adding this new daemon dependency without committing the matching Cargo.lock update leaves the lockfile's mizan-daemon entry without mizan-providers or the newly added uuid dependency. I checked cargo check --help, where --locked is documented as asserting that Cargo.lock remains unchanged, so locked/frozen or reproducible build environments will need to modify the committed lockfile and can fail; please regenerate and commit Cargo.lock with these new daemon deps.

Useful? React with 👍 / 👎.

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