Skip to content

refactor(agent): migrate Build session operations to the repository - #46221

Merged
hjlarry merged 8 commits into
mainfrom
hjlarry/agent-build-session
Nov 20, 2026
Merged

hjlarry merged 8 commits into
mainfrom
hjlarry/agent-build-session

Conversation

@hjlarry

@hjlarry hjlarry commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Move Agent Build conversation refresh and Build draft read and discard into injected use cases backed by AgentAppRepository. The controller admits the account, validates the request, and translates application errors.

Follow-up to #46159. Part of #39993.

  • Commit conversation replacement, draft changes, and retained Sandbox binding retirement together. Publish resource collection after commit.
  • Reuse shared draft queries and metadata projection across the Build routes and the legacy Config Inspector.
  • Return 404 agent_build_sandbox_not_found when discard encounters a retained binding from an outdated generation. Refresh can reset an owned binding from an older generation.
  • Update the generated Console API reference and contracts.

Screenshots

Checklist

  • Added real HTTP/SQLite coverage for account and tenant isolation, stale binding handling, rollback, and publication after commit.
  • Verified the updated branch with 478 focused tests, type checks, style checks, import-boundary contracts, and response-contract lint.

@github-actions github-actions Bot added web This relates to changes on the web. size:XXL This PR changes 1000+ lines, ignoring generated files. labels Nov 13, 2026
@hjlarry
hjlarry added this pull request to stack #46094 November 13, 2026 05:21
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 87.05% 87.06% +0.01%
Strict coverage 86.71% 86.72% +0.01%
Typed symbols 96,155 96,217 +62
Untyped symbols 14,361 14,355 -6
Modules 4641 4646 +5

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-11-20 09:27:47.502684274 +0000
+++ /tmp/pyrefly_pr.txt	2026-11-20 09:27:21.458450445 +0000
@@ -4982,55 +4982,55 @@
 ERROR Object of class `NoneType` has no attribute `agent_workspace_binding_id` [missing-attribute]
     --> tests/unit_tests/services/agent/test_roster_service.py:1527:12
 ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `AgentIconType | SQLCoreOperations[AgentIconType | None] | None` in function `models.agent.Agent.__init__` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_roster_service.py:2576:19
+    --> tests/unit_tests/services/agent/test_roster_service.py:2427:19
 ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `AgentIconType | SQLCoreOperations[AgentIconType | None] | None` in function `models.agent.Agent.__init__` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_roster_service.py:2732:19
+    --> tests/unit_tests/services/agent/test_roster_service.py:2583:19
 ERROR Object of class `object` has no attribute `prompt` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:3152:12
+    --> tests/unit_tests/services/agent/test_roster_service.py:3003:12
 ERROR Cannot index into `object` [bad-index]
-    --> tests/unit_tests/services/agent/test_roster_service.py:3343:12
+    --> tests/unit_tests/services/agent/test_roster_service.py:3194:12
 ERROR Cannot index into `object` [bad-index]
-    --> tests/unit_tests/services/agent/test_roster_service.py:3344:12
+    --> tests/unit_tests/services/agent/test_roster_service.py:3195:12
 ERROR Cannot index into `object` [bad-index]
-    --> tests/unit_tests/services/agent/test_roster_service.py:3345:12
+    --> tests/unit_tests/services/agent/test_roster_service.py:3196:12
 ERROR Argument `list[str | None]` is not assignable to parameter `version_ids` with type `list[str]` in function `services.agent.roster_service.AgentRosterService._load_versions_by_id` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_roster_service.py:4416:52
+    --> tests/unit_tests/services/agent/test_roster_service.py:4267:52
 ERROR Argument `Literal[0]` is not assignable to parameter `message_unit_price` with type `Decimal | SQLCoreOperations[Decimal]` in function `models.model.Message.__init__` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_roster_service.py:4575:36
+    --> tests/unit_tests/services/agent/test_roster_service.py:4426:36
 ERROR Argument `Literal[0]` is not assignable to parameter `answer_unit_price` with type `Decimal | SQLCoreOperations[Decimal]` in function `models.model.Message.__init__` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_roster_service.py:4577:35
+    --> tests/unit_tests/services/agent/test_roster_service.py:4428:35
 ERROR Argument `Literal[0]` is not assignable to parameter `total_price` with type `Decimal | SQLCoreOperations[Decimal | None] | None` in function `models.model.Message.__init__` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_roster_service.py:4578:29
+    --> tests/unit_tests/services/agent/test_roster_service.py:4429:29
 ERROR Object of class `NoneType` has no attribute `conversation_id` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5338:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5074:16
 ERROR Argument `Literal['simple']` is not assignable to parameter `prompt_type` with type `PromptType | SQLCoreOperations[PromptType]` in function `models.model.AppModelConfig.__init__` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5446:25
+    --> tests/unit_tests/services/agent/test_roster_service.py:5095:25
 ERROR Unpacked keyword argument `Any | None` is not assignable to parameter `prompt_type` with type `PromptType | SQLCoreOperations[PromptType]` in function `models.model.AppModelConfig.__init__` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5454:34
+    --> tests/unit_tests/services/agent/test_roster_service.py:5103:34
 ERROR Object of class `object` has no attribute `name` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5560:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5209:16
 ERROR Object of class `object` has no attribute `mode` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5561:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5210:16
 ERROR Object of class `object` has no attribute `agent_role` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5562:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5211:16
 ERROR Object of class `object` has no attribute `config_snapshot` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5572:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5221:16
 ERROR Object of class `object` has no attribute `home_snapshot_id` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5574:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5223:16
 ERROR Object of class `object` has no attribute `summary` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5575:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5224:16
 ERROR Object of class `object` has no attribute `version_note` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5576:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5225:16
 ERROR Object of class `object` has no attribute `active_config_has_model` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5577:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5226:16
 ERROR Object of class `object` has no attribute `active_config_is_published` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5578:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5227:16
 ERROR Object of class `object` has no attribute `updated_by` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5579:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5228:16
 ERROR Object of class `object` has no attribute `id` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5580:35
+    --> tests/unit_tests/services/agent/test_roster_service.py:5229:35
 ERROR Object of class `object` has no attribute `agent_role` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_roster_service.py:5650:16
+    --> tests/unit_tests/services/agent/test_roster_service.py:5299:16
 ERROR Class member `StubResolver.resolve` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
    --> tests/unit_tests/services/data_migration/test_import_service.py:256:13
 ERROR Class member `CapturingImportService._import_workflows` overrides parent class `MigrationImportService` in an inconsistent manner [bad-override]

@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.87500% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.41%. Comparing base (764f172) to head (870726b).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
api/repositories/app/agent_app_repository.py 88.70% 3 Missing and 4 partials ⚠️
api/services/agent/composer_service.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #46221      +/-   ##
==========================================
+ Coverage   90.30%   90.41%   +0.10%     
==========================================
  Files        6463     6387      -76     
  Lines      408169   405693    -2476     
  Branches    81855    80957     -898     
==========================================
- Hits       368597   366805    -1792     
+ Misses      33162    32483     -679     
+ Partials     6410     6405       -5     
Flag Coverage Δ
api 90.12% <96.87%> (+0.01%) ⬆️
cli 94.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hjlarry
hjlarry marked this pull request as ready for review November 13, 2026 05:47
@hjlarry
hjlarry force-pushed the hjlarry/agent-build-session branch 2 times, most recently from d70f0e7 to 66f315e Compare November 13, 2026 09:34
Resolve default model selection before the creation transaction, and persist the App, backing Agent, and Build conversation together. Share Soul configuration helpers without adding Agent service dependencies to persistence.
Use Console account admission for Build conversation refresh and draft reads and discards. Commit the draft and binding changes together before scheduling resource collection.
Report an unavailable sandbox when discarding a draft with a stale binding. Cover refresh and archived Agent compatibility, share draft metadata across readers, and register the Build routes explicitly.
@hjlarry
hjlarry force-pushed the hjlarry/agent-build-session branch from 66f315e to 4a32b3a Compare November 14, 2026 06:19
Base automatically changed from hjlarry/agent-app-lifecycle-persistence to main November 20, 2026 08:27
@hjlarry
hjlarry added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 20, 2026
@hjlarry
hjlarry added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 0120a32 Nov 20, 2026
66 checks passed
@hjlarry
hjlarry deleted the hjlarry/agent-build-session branch November 20, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants