Skip to content

fix(BA-5665): apply VFolder model-definition.yaml override for all runtime variants on Agent#10984

Draft
jopemachine wants to merge 4 commits intomainfrom
fix/BA-5665-agent-read-model-definition
Draft

fix(BA-5665): apply VFolder model-definition.yaml override for all runtime variants on Agent#10984
jopemachine wants to merge 4 commits intomainfrom
fix/BA-5665-agent-read-model-definition

Conversation

@jopemachine
Copy link
Copy Markdown
Member

@jopemachine jopemachine commented Apr 12, 2026

Summary

  • Agent was ignoring VFolder model-definition.yaml for non-custom runtime variants (vllm, tgi, nim, sglang, modular-max), using only hardcoded defaults
  • Now reads VFolder yaml and deep-merges it on top of variant defaults using ModelDefinition.merge(), mirroring Manager's _apply_vfolder_override() in definition_generator/registry.py

Jira

BA-5665

Changes (1 file: agent/agent.py)

  • Extract _read_model_definition_from_vfolder() (required, for custom) and _try_read_model_definition_from_vfolder() (optional, returns None if not found) from inline custom variant code
  • After variant-specific base generation, call _try_read_model_definition_from_vfolder() and base.merge(override) for non-custom variants
  • Custom variant uses the same extracted helper

Approach

Agent reads VFolder yaml directly — same approach Manager already uses. Works for both legacy (POST /services) and sokovan (POST /v2/deployments) paths without Manager-side changes.

See #10951 for the alternative approach (Manager → Agent passing) which was drafted because it breaks the legacy WebUI path.

Test plan

  • Deploy custom variant service with VFolder health_check override → verify applied
  • Deploy non-custom variant with VFolder health_check override → verify applied
  • Deploy non-custom variant without VFolder yaml → verify defaults used
  • Verify Agent log: "applied VFolder model-definition.yaml override"

🤖 Generated with Claude Code

…stom runtime variants

Agent was ignoring VFolder model-definition.yaml for non-custom
runtime variants (vllm, tgi, nim, sglang, modular-max), using only
hardcoded defaults. Now reads the VFolder yaml and deep-merges it
on top of variant defaults, mirroring Manager's _apply_vfolder_override().

Extract _read_model_definition_from_vfolder() and
_try_read_model_definition_from_vfolder() helpers to share VFolder
reading logic between custom (required) and non-custom (optional
override) variants.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Agent’s runtime model definition loading so that non-custom runtime variants can optionally apply user-provided model-definition.yaml overrides from the model VFolder (deep-merged on top of variant defaults), aligning behavior with the Manager’s merge strategy.

Changes:

  • Added Agent-side reading of model-definition.yaml from the model VFolder for non-custom runtime variants and deep-merge via ModelDefinition.merge().
  • Refactored VFolder YAML reading into _read_model_definition_from_vfolder() and _try_read_model_definition_from_vfolder().
  • Added a towncrier news fragment documenting the behavioral fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/ai/backend/agent/agent.py Reads optional VFolder model-definition overrides for non-custom variants and merges them into generated defaults; refactors YAML reading into helpers.
changes/10952.fix.md News fragment describing the Agent-side override behavior change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ai/backend/agent/agent.py Outdated
Comment thread src/ai/backend/agent/agent.py Outdated
Comment thread src/ai/backend/agent/agent.py Outdated
@jopemachine jopemachine force-pushed the fix/BA-5665-agent-read-model-definition branch from 5ad67f3 to 5af3b4a Compare April 12, 2026 10:29
@github-actions github-actions bot added comp:manager Related to Manager component comp:common Related to Common component labels Apr 12, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jopemachine jopemachine force-pushed the fix/BA-5665-agent-read-model-definition branch from 5af3b4a to 36ab267 Compare April 12, 2026 10:31
jopemachine and others added 2 commits April 12, 2026 19:34
- Wrap VFolder override merge in try/except, fall back to variant
  defaults on failure (mirrors Manager's _try_merge_vfolder_definition)
- Validate yaml.load() returns a mapping, raise on list/string/None
- Log warning (with traceback) when VFolder yaml exists but is invalid,
  silently skip only when file is not found

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests for:
- VFolder override applied for non-custom variants (parametrized)
- Fallback to hardcoded defaults when no VFolder yaml
- Graceful fallback on invalid YAML, non-mapping YAML, merge failure
- _read/_try_read helpers: parsed yaml, missing file, invalid file,
  custom definition_path from internal_data

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jopemachine jopemachine reopened this Apr 13, 2026
@jopemachine jopemachine added this to the 26.4 milestone Apr 13, 2026
@jopemachine jopemachine marked this pull request as draft April 14, 2026 04:44
@jopemachine
Copy link
Copy Markdown
Member Author

Although this PR only removes dead code, I am keeping it as a draft for now to avoid any unintended side effects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:agent Related to Agent component comp:common Related to Common component comp:manager Related to Manager component size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants