mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor: remove legacy live-read and injected-history chat context paths (#26585)
This PR makes the agent-pushed pinned snapshot (`chat_context_resources`) the sole source of workspace context for chats, completing the "Release 5" cleanup. It removes legacy mechanisms now superseded by the snapshot that agents push over dRPC (`PushContextState`) and refresh via `chat-context/refresh`. Removed: - **Live-read at turn time.** MCP tool discovery, skill live-body reads, and the instruction/skill history fallback that dialed the workspace on every turn. - **Context injected as message history.** The `persist_workspace_context` generation action and its decision-loop guard. - **The legacy write path.** `POST`/`DELETE /api/v2/workspaceagents/me/experimental/chat-context`, the agentsdk `AddChatContext`/`ClearChatContext` methods, and the CLI one-shot writer. - **The `chats.last_injected_context` column** and all of its plumbing (migration `000529`, queries, `db2sdk`, `dbauthz`, audit table, and the frontend `ContextUsageIndicator` fallback). Subagent context inheritance no longer copies parent context messages; children now hydrate the parent's pinned `chat_context_resources` on create, which yields an identical pin for the same workspace and agent. What stays (still served by the live agent connection, not the snapshot): `read_skill_file` supporting-file reads, `read_skill` supporting-file listing, and MCP tool execution. > [!NOTE] > Migration `000529` drops `chats.last_injected_context` and recreates the `chats_expanded` view without it. The down migration restores both. <details> <summary>Decision log (D1-D5)</summary> - **D1 (subagent inheritance):** Re-point inheritance from the legacy message copy to a pinned hydrate. Children call `hydrateChatContextOnCreate` instead of copying parent context messages. - **D2 (`persist_workspace_context`):** Remove the generation action entirely along with the decision-loop guard it existed to satisfy, since context is never injected into history anymore. - **D3 (legacy HTTP + CLI):** Remove the experimental `chat-context` POST/DELETE endpoints, the agentsdk methods, and the CLI one-shot. The dRPC push + `chat-context/refresh` replace them. - **D4 (frontend fallback):** Remove the `last_injected_context` fallback in `ContextUsageIndicator`; pinned `resources` are the sole source. - **D5 (sequencing):** Ship as a single PR rather than a stacked pair. </details> --- Coder Agents generated on behalf of @kylecarbs.
This commit is contained in:
Generated
+79
-1022
File diff suppressed because it is too large
Load Diff
Generated
+33
-226
@@ -2080,70 +2080,6 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"retryable": true,
|
||||
"status_code": 0
|
||||
},
|
||||
"last_injected_context": [
|
||||
{
|
||||
"args": [
|
||||
0
|
||||
],
|
||||
"args_delta": "string",
|
||||
"completed_at": "2019-08-24T14:15:22Z",
|
||||
"content": "string",
|
||||
"context_file_agent_id": {
|
||||
"uuid": "string",
|
||||
"valid": true
|
||||
},
|
||||
"context_file_content": "string",
|
||||
"context_file_directory": "string",
|
||||
"context_file_os": "string",
|
||||
"context_file_path": "string",
|
||||
"context_file_skill_meta_file": "string",
|
||||
"context_file_truncated": true,
|
||||
"created_at": "2019-08-24T14:15:22Z",
|
||||
"data": [
|
||||
0
|
||||
],
|
||||
"end_line": 0,
|
||||
"file_id": {
|
||||
"uuid": "string",
|
||||
"valid": true
|
||||
},
|
||||
"file_name": "string",
|
||||
"is_error": true,
|
||||
"is_media": true,
|
||||
"mcp_server_config_id": {
|
||||
"uuid": "string",
|
||||
"valid": true
|
||||
},
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
]
|
||||
],
|
||||
"provider_executed": true,
|
||||
"provider_metadata": [
|
||||
0
|
||||
],
|
||||
"result": [
|
||||
0
|
||||
],
|
||||
"result_delta": "string",
|
||||
"result_reset": true,
|
||||
"signature": "string",
|
||||
"skill_description": "string",
|
||||
"skill_dir": "string",
|
||||
"skill_name": "string",
|
||||
"source_id": "string",
|
||||
"start_line": 0,
|
||||
"text": "string",
|
||||
"title": "string",
|
||||
"tool_call_id": "string",
|
||||
"tool_name": "string",
|
||||
"type": "text",
|
||||
"url": "string"
|
||||
}
|
||||
],
|
||||
"last_model_config_id": "30ebb95f-c255-4759-9429-89aa4ec1554c",
|
||||
"last_turn_summary": "string",
|
||||
"mcp_server_ids": [
|
||||
@@ -2236,70 +2172,6 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"retryable": true,
|
||||
"status_code": 0
|
||||
},
|
||||
"last_injected_context": [
|
||||
{
|
||||
"args": [
|
||||
0
|
||||
],
|
||||
"args_delta": "string",
|
||||
"completed_at": "2019-08-24T14:15:22Z",
|
||||
"content": "string",
|
||||
"context_file_agent_id": {
|
||||
"uuid": "string",
|
||||
"valid": true
|
||||
},
|
||||
"context_file_content": "string",
|
||||
"context_file_directory": "string",
|
||||
"context_file_os": "string",
|
||||
"context_file_path": "string",
|
||||
"context_file_skill_meta_file": "string",
|
||||
"context_file_truncated": true,
|
||||
"created_at": "2019-08-24T14:15:22Z",
|
||||
"data": [
|
||||
0
|
||||
],
|
||||
"end_line": 0,
|
||||
"file_id": {
|
||||
"uuid": "string",
|
||||
"valid": true
|
||||
},
|
||||
"file_name": "string",
|
||||
"is_error": true,
|
||||
"is_media": true,
|
||||
"mcp_server_config_id": {
|
||||
"uuid": "string",
|
||||
"valid": true
|
||||
},
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
]
|
||||
],
|
||||
"provider_executed": true,
|
||||
"provider_metadata": [
|
||||
0
|
||||
],
|
||||
"result": [
|
||||
0
|
||||
],
|
||||
"result_delta": "string",
|
||||
"result_reset": true,
|
||||
"signature": "string",
|
||||
"skill_description": "string",
|
||||
"skill_dir": "string",
|
||||
"skill_name": "string",
|
||||
"source_id": "string",
|
||||
"start_line": 0,
|
||||
"text": "string",
|
||||
"title": "string",
|
||||
"tool_call_id": "string",
|
||||
"tool_name": "string",
|
||||
"type": "text",
|
||||
"url": "string"
|
||||
}
|
||||
],
|
||||
"last_model_config_id": "30ebb95f-c255-4759-9429-89aa4ec1554c",
|
||||
"last_turn_summary": "string",
|
||||
"mcp_server_ids": [
|
||||
@@ -2326,40 +2198,39 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|-------------------------|-----------------------------------------------------------------|----------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `agent_id` | string | false | | |
|
||||
| `archived` | boolean | false | | |
|
||||
| `build_id` | string | false | | |
|
||||
| `children` | array of [codersdk.Chat](#codersdkchat) | false | | Children holds child (subagent) chats nested under this root chat. Always initialized to an empty slice so the JSON field is present as []. Child chats cannot create their own subagents, so nesting depth is capped at 1 and this slice is always empty for child chats. |
|
||||
| `client_type` | [codersdk.ChatClientType](#codersdkchatclienttype) | false | | |
|
||||
| `context` | [codersdk.ChatContext](#codersdkchatcontext) | false | | Context reports the chat's pinned workspace-context state and whether it has drifted from the agent's latest pushed snapshot. Nil when the chat has no pinned context yet. |
|
||||
| `created_at` | string | false | | |
|
||||
| `diff_status` | [codersdk.ChatDiffStatus](#codersdkchatdiffstatus) | false | | |
|
||||
| `files` | array of [codersdk.ChatFileMetadata](#codersdkchatfilemetadata) | false | | |
|
||||
| `has_unread` | boolean | false | | Has unread is true when assistant messages exist beyond the owner's read cursor, which updates on stream connect and disconnect. |
|
||||
| `id` | string | false | | |
|
||||
| `labels` | object | false | | |
|
||||
| » `[any property]` | string | false | | |
|
||||
| `last_error` | [codersdk.ChatError](#codersdkchaterror) | false | | |
|
||||
| `last_injected_context` | array of [codersdk.ChatMessagePart](#codersdkchatmessagepart) | false | | Last injected context holds the most recently persisted injected context parts (AGENTS.md files and skills). It is updated only when context changes, on first workspace attach or agent change. |
|
||||
| `last_model_config_id` | string | false | | |
|
||||
| `last_turn_summary` | string | false | | |
|
||||
| `mcp_server_ids` | array of string | false | | |
|
||||
| `organization_id` | string | false | | |
|
||||
| `owner_id` | string | false | | |
|
||||
| `owner_name` | string | false | | |
|
||||
| `owner_username` | string | false | | |
|
||||
| `parent_chat_id` | string | false | | |
|
||||
| `pin_order` | integer | false | | |
|
||||
| `plan_mode` | [codersdk.ChatPlanMode](#codersdkchatplanmode) | false | | |
|
||||
| `root_chat_id` | string | false | | |
|
||||
| `shared` | boolean | false | | Shared is true when this chat's root chat has explicit user or group ACL entries. |
|
||||
| `status` | [codersdk.ChatStatus](#codersdkchatstatus) | false | | |
|
||||
| `title` | string | false | | |
|
||||
| `updated_at` | string | false | | |
|
||||
| `warnings` | array of string | false | | |
|
||||
| `workspace_id` | string | false | | |
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|------------------------|-----------------------------------------------------------------|----------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `agent_id` | string | false | | |
|
||||
| `archived` | boolean | false | | |
|
||||
| `build_id` | string | false | | |
|
||||
| `children` | array of [codersdk.Chat](#codersdkchat) | false | | Children holds child (subagent) chats nested under this root chat. Always initialized to an empty slice so the JSON field is present as []. Child chats cannot create their own subagents, so nesting depth is capped at 1 and this slice is always empty for child chats. |
|
||||
| `client_type` | [codersdk.ChatClientType](#codersdkchatclienttype) | false | | |
|
||||
| `context` | [codersdk.ChatContext](#codersdkchatcontext) | false | | Context reports the chat's pinned workspace-context state and whether it has drifted from the agent's latest pushed snapshot. Nil when the chat has no pinned context yet. |
|
||||
| `created_at` | string | false | | |
|
||||
| `diff_status` | [codersdk.ChatDiffStatus](#codersdkchatdiffstatus) | false | | |
|
||||
| `files` | array of [codersdk.ChatFileMetadata](#codersdkchatfilemetadata) | false | | |
|
||||
| `has_unread` | boolean | false | | Has unread is true when assistant messages exist beyond the owner's read cursor, which updates on stream connect and disconnect. |
|
||||
| `id` | string | false | | |
|
||||
| `labels` | object | false | | |
|
||||
| » `[any property]` | string | false | | |
|
||||
| `last_error` | [codersdk.ChatError](#codersdkchaterror) | false | | |
|
||||
| `last_model_config_id` | string | false | | |
|
||||
| `last_turn_summary` | string | false | | |
|
||||
| `mcp_server_ids` | array of string | false | | |
|
||||
| `organization_id` | string | false | | |
|
||||
| `owner_id` | string | false | | |
|
||||
| `owner_name` | string | false | | |
|
||||
| `owner_username` | string | false | | |
|
||||
| `parent_chat_id` | string | false | | |
|
||||
| `pin_order` | integer | false | | |
|
||||
| `plan_mode` | [codersdk.ChatPlanMode](#codersdkchatplanmode) | false | | |
|
||||
| `root_chat_id` | string | false | | |
|
||||
| `shared` | boolean | false | | Shared is true when this chat's root chat has explicit user or group ACL entries. |
|
||||
| `status` | [codersdk.ChatStatus](#codersdkchatstatus) | false | | |
|
||||
| `title` | string | false | | |
|
||||
| `updated_at` | string | false | | |
|
||||
| `warnings` | array of string | false | | |
|
||||
| `workspace_id` | string | false | | |
|
||||
|
||||
## codersdk.ChatACL
|
||||
|
||||
@@ -4061,70 +3932,6 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"retryable": true,
|
||||
"status_code": 0
|
||||
},
|
||||
"last_injected_context": [
|
||||
{
|
||||
"args": [
|
||||
0
|
||||
],
|
||||
"args_delta": "string",
|
||||
"completed_at": "2019-08-24T14:15:22Z",
|
||||
"content": "string",
|
||||
"context_file_agent_id": {
|
||||
"uuid": "string",
|
||||
"valid": true
|
||||
},
|
||||
"context_file_content": "string",
|
||||
"context_file_directory": "string",
|
||||
"context_file_os": "string",
|
||||
"context_file_path": "string",
|
||||
"context_file_skill_meta_file": "string",
|
||||
"context_file_truncated": true,
|
||||
"created_at": "2019-08-24T14:15:22Z",
|
||||
"data": [
|
||||
0
|
||||
],
|
||||
"end_line": 0,
|
||||
"file_id": {
|
||||
"uuid": "string",
|
||||
"valid": true
|
||||
},
|
||||
"file_name": "string",
|
||||
"is_error": true,
|
||||
"is_media": true,
|
||||
"mcp_server_config_id": {
|
||||
"uuid": "string",
|
||||
"valid": true
|
||||
},
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
]
|
||||
],
|
||||
"provider_executed": true,
|
||||
"provider_metadata": [
|
||||
0
|
||||
],
|
||||
"result": [
|
||||
0
|
||||
],
|
||||
"result_delta": "string",
|
||||
"result_reset": true,
|
||||
"signature": "string",
|
||||
"skill_description": "string",
|
||||
"skill_dir": "string",
|
||||
"skill_name": "string",
|
||||
"source_id": "string",
|
||||
"start_line": 0,
|
||||
"text": "string",
|
||||
"title": "string",
|
||||
"tool_call_id": "string",
|
||||
"tool_name": "string",
|
||||
"type": "text",
|
||||
"url": "string"
|
||||
}
|
||||
],
|
||||
"last_model_config_id": "30ebb95f-c255-4759-9429-89aa4ec1554c",
|
||||
"last_turn_summary": "string",
|
||||
"mcp_server_ids": [
|
||||
|
||||
Reference in New Issue
Block a user