fix(runtime): persist resolved model name to DB even when not explicitly provided#3110
Open
yitang wants to merge 1 commit into
Open
fix(runtime): persist resolved model name to DB even when not explicitly provided#3110yitang wants to merge 1 commit into
yitang wants to merge 1 commit into
Conversation
…tly provided Remove the 'record.model_name is not None' guard in worker.py so that runs created without an explicit model_name (which leaves it as None) still get their resolved effective model persisted from agent metadata. Previously, when no model_name was passed in the request context, the update_model_name call was skipped entirely because of an early-exit condition, leaving the DB column permanently NULL. Closes bytedance#3109
WillemJiang
approved these changes
May 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes run metadata persistence so the runs.model_name column is populated even when the user doesn’t explicitly provide a model name, by persisting the agent-resolved effective model name during runtime.
Changes:
- Update
run_agent()to always readagent.metadata["model_name"](when available) and persist it viarun_manager.update_model_name(...). - Add
.agents/plans/to.gitignore.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| backend/packages/harness/deerflow/runtime/runs/worker.py | Removes the record.model_name is not None guard and persists the resolved effective model name from agent metadata. |
| .gitignore | Ignores .agents/plans/ directory. |
Comments suppressed due to low confidence (1)
backend/packages/harness/deerflow/runtime/runs/worker.py:244
- The new logic updates the run’s model_name whenever
effectiveis truthy, even if it’s identical to the already-persisted value. Because the SQL store’supdate_model_namealways writesupdated_at(and doesn’t short-circuit on same value), this introduces an extra DB write and changes semantics by bumpingupdated_atfor runs that already had the correct model_name. Consider restoring a value-change guard, e.g. only callupdate_model_namewheneffectiveis set andeffective != record.model_name(this still fixes theNonecase sinceNone != effective).
resolved = getattr(agent, "metadata", {}) or {}
if isinstance(resolved, dict):
effective = resolved.get("model_name")
if effective:
await run_manager.update_model_name(record.run_id, effective)
Comment on lines
+237
to
+244
| # NOTE: Removed the "record.model_name is not None" guard so that runs | ||
| # created without an explicit model_name (which leaves it as None) still | ||
| # get their resolved effective model persisted to the database. | ||
| resolved = getattr(agent, "metadata", {}) or {} | ||
| if isinstance(resolved, dict): | ||
| effective = resolved.get("model_name") | ||
| if effective: | ||
| await run_manager.update_model_name(record.run_id, effective) |
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.
Summary
Fixes the
model_namecolumn in therunsdatabase table being permanently empty. When a user starts a run without specifying amodel_namein the request context, the agent resolves an effective model at runtime, but this was never persisted to the database due to a guard condition that skipped the update entirely whenrecord.model_namewasNone.Changes
File:
backend/packages/harness/deerflow/runtime/runs/worker.py(lines 237–242)"record.model_name is not None"early-exit guardmodel_namewas already set at creation time, behavior is unchanged (same or different effective model gets written)model_namewas never set (the bug case), the resolved default model is now correctly persistedTest Plan
tests/test_run_manager.pypass (includingtest_model_name_create_or_reject,test_model_name_default_is_none)model_name, query the DB to confirm it's populatedRelated Issues
Closes #3109