Skip to content

fix: backfill model on gateway sessions after agent runs#988

Closed
heyalchang wants to merge 1 commit intoNousResearch:mainfrom
heyalchang:fix/gateway-session-model-backfill
Closed

fix: backfill model on gateway sessions after agent runs#988
heyalchang wants to merge 1 commit intoNousResearch:mainfrom
heyalchang:fix/gateway-session-model-backfill

Conversation

@heyalchang
Copy link

Closes #987.

After _run_agent() finishes, agent.model is available but was never written back to the sessions table. This PR threads the model through the return dict and into update_session() / update_token_counts(), using COALESCE so it only fills NULL — never overwrites a model already set.

Adds optional `model` param to `update_token_counts()` and
`update_session()`. Both return dicts in `_run_agent()` now include
`agent.model`, and `_handle_message()` passes it through so gateway
sessions no longer have NULL model in the DB.

Closes NousResearch#987

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@heyalchang
Copy link
Author

Superseded by #997 — cleaner implementation (single COALESCE query, no whitespace noise).

@heyalchang heyalchang closed this Mar 12, 2026
@heyalchang heyalchang deleted the fix/gateway-session-model-backfill branch March 12, 2026 01:17
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.

Gateway sessions have NULL model in DB

1 participant