codegen: share build_codegen_client and fix its integration test

Extract build_codegen_client() from build_scheduler so the codegen client
(provider class plus auth/User-Agent) is constructed in one place, and use it
in test_generate_skill_body_codegen, which previously hardcoded a plain
CodegenClient and 403'd against the Console provider.
This commit is contained in:
gabby committed 2026-10-03 18:07:22 +00:00
1 parent e81e6c3a6b
commit 8426b85ce0
2 files changed
+51 -47

No files matched your search

+6 -13
View File
@@ -13,8 +13,7 @@ import time
import pytest
from semif_agent.cli import (
_opt_float,
_required_model,
build_codegen_client,
build_engine_config,
build_scheduler,
load_config,
@@ -297,17 +296,11 @@ def test_generate_skill_body_codegen(tmp_path):
"""
config = load_config()
require_real(config)
codegen_cfg = config.get("codegen", {})
client = CodegenClient(
base_url=codegen_cfg.get("base_url", "http://localhost:11434/v1"),
model=_required_model(codegen_cfg, "codegen"),
timeout=float(codegen_cfg.get("timeout", 1200.0)),
stream=True,
temperature=_opt_float(codegen_cfg.get("temperature")),
top_p=_opt_float(codegen_cfg.get("top_p")),
presence_penalty=_opt_float(codegen_cfg.get("presence_penalty")),
frequency_penalty=_opt_float(codegen_cfg.get("frequency_penalty")),
)
# Build the client exactly as build_scheduler does, so the test exercises the
# configured provider (e.g. the hosted Console, which needs auth + a
# User-Agent) rather than assuming an unauthenticated ollama endpoint.
config["codegen"] = {**(config.get("codegen") or {}), "stream": True}
client = build_codegen_client(config)
tree = build_tree(build_skills({"skills": {}}))
draft = SkillDraft(
name="check_service",