Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,12 @@ live, durable, diagnostic, and usage Adapters (Phase 5, separately designed).
Through Gate 4, hosted durable and AG-UI production projections still consume
compatibility UI chunks, and production runs stay on stream protocol
version 1.

## Provider Message Conversion

The single owner of turning a chat's replay history into the ordered message
list a provider sees: `src/chat/provider-message-conversion.ts`. It asks Tool
Replay Reconciliation which tool occurrences are authoritative, maps each role's
parts into provider content, and settles into one `ProviderModelMessage[]`.
Message preparation and the compatibility layer are callers; neither re-derives
the mapping.
8 changes: 5 additions & 3 deletions scripts/lint/ban-chat-antipatterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ const FILE_SIZE_CEILINGS: Record<string, number> = {
// real seams (part-field-access, message-part-parsing, tool-replay
// reconciliation). Not React components, so this map does not subject them
// to the antipattern ratchets above — it only pins their size.
"src/chat/conversation.ts": 1018,
"src/chat/conversation.ts": 557,
"src/chat/message-prep.ts": 2016,
"src/chat/tool-replay-reconciliation.ts": 294,
"src/chat/tool-replay-reconciliation.ts": 291,
"src/chat/message-part-parsing.ts": 264,
"src/chat/part-field-access.ts": 66,
"src/chat/part-field-access.ts": 65,
"src/chat/provider-input-types.ts": 34,
"src/chat/provider-message-conversion.ts": 447,
};

function checkFileSizes(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/agent/hosted/chat-request.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "#veryfront/schemas/_test-setup.ts";
import { convertUiMessagesToProviderModelMessages } from "#veryfront/chat/conversation";
import { convertUiMessagesToProviderModelMessages } from "../../chat/provider-message-conversion.ts";
import { assertEquals, assertStringIncludes } from "#veryfront/testing/assert.ts";
import { describe, it } from "#veryfront/testing/bdd.ts";
import { DEFAULT_MAX_BODY_SIZE_BYTES } from "#veryfront/utils/constants/index.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/chat/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import {
getAgUiWireEventSchema,
} from "./ag-ui.ts";
import {
convertUiMessagesToProviderModelMessages,
getApiConversationSchema,
getApiMessageSchema,
getConversationTypeSchema,
getMessagePartSchema,
getMessageStatusSchema,
} from "./conversation.ts";
import { convertUiMessagesToProviderModelMessages } from "./provider-message-conversion.ts";
import {
prepareProviderModelMessagesFromUiMessages,
sanitizeProviderModelMessages,
Expand Down
4 changes: 2 additions & 2 deletions src/chat/conversation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
ChatProviderModelInputMessage,
ChatProviderModelInputPart,
ChatProviderModelInputToolResultPart,
} from "#veryfront/chat/conversation";
} from "./provider-input-types.ts";
import type {
ChatToolCallPart,
ChatToolPartState,
Expand All @@ -21,7 +21,6 @@ import {
messageStatusSchema,
} from "#veryfront/chat/compat";
import {
convertUiMessagesToProviderModelMessages,
extractTextFromMessage,
extractUploadId,
hasIncompleteToolParts,
Expand All @@ -34,6 +33,7 @@ import {
stringifyUnknown,
toConversationPartsFromUiMessage,
} from "#veryfront/chat/conversation";
import { convertUiMessagesToProviderModelMessages } from "./provider-message-conversion.ts";

const GITHUB_PR_DIFF_INPUT = { owner: "veryfront", repo: "veryfront-code", pull_number: 3092 };
const GITHUB_LIST_PRS_INPUT = { owner: "veryfront", repo: "veryfront-code" };
Expand Down
Loading