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
8 changes: 0 additions & 8 deletions apps/web/src/ai/mastra/memory/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ const JOURNL_MEMORY_LAST_MESSAGES = 30;
const JOURNL_OBSERVATIONAL_MEMORY_SCOPE = "resource";
const JOURNL_OBSERVATIONAL_TOKENS = 30000;
const JOURNL_REFLECTION_TOKENS = 40000;
const JOURNL_SEMANTIC_SEARCH_RANGE = 2;
const JOURNL_SEMANTIC_SEARCH_SCOPE = "thread";
const JOURNL_SEMANTIC_TOP_K = 3;
const JOURNL_WORKING_MEMORY_SCOPE = "resource";
const JOURNL_WORKING_MEMORY_TEMPLATE = `## Preferences

Expand Down Expand Up @@ -47,11 +44,6 @@ export const journlMemory = new Memory({
// disabling to free context window space for the messaging history, etc.
shareTokenBudget: false,
},
semanticRecall: {
messageRange: JOURNL_SEMANTIC_SEARCH_RANGE,
scope: JOURNL_SEMANTIC_SEARCH_SCOPE,
topK: JOURNL_SEMANTIC_TOP_K,
},
workingMemory: {
enabled: true,
scope: JOURNL_WORKING_MEMORY_SCOPE,
Expand Down
8 changes: 7 additions & 1 deletion apps/web/src/ai/tools/write/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export function useWriteTool() {
execute: async (toolCall, chat) => {
let cleanUpBeforeChange: CallableFunction | undefined;

if (env.NODE_ENV === "development") {
console.debug("[useWriteTool]", {
input: toolCall.input,
});
}

try {
const editor = getEditor(toolCall.input.targetEditor)(getEditors);
const aiExtension = getAIExtension(editor);
Expand All @@ -40,7 +46,7 @@ export function useWriteTool() {
await aiExtension.invokeAI({
chatRequestOptions: {
body: {
reasoningEffort: toolCall.input.reasoningEffort ?? "low",
reasoningEffort: toolCall.input.reasoningEffort ?? "minimal",
} satisfies Pick<BlockNoteRequest, "reasoningEffort">,
},
deleteEmptyCursorBlock: false,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/ai/tools/write/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const zWriteInput = z.object({
reasoningEffort: z
.optional(zOpenAIReasoningEffort)
.describe(
"Optional reasoning effort for this edit. Use `low` for normal edits, `medium` for multi-section rewrites, and `high` for the most complex asks. Defaults to `low` if omitted.",
"Optional reasoning effort for this edit. Use `minimal` for normal edits, `low` for multi-section rewrites, and `medium` for complex tasks, or `high` for the most creative asks. Defaults to `minimal` if omitted.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Align reasoningEffort default with runtime behavior

The schema description now says omitted reasoningEffort defaults to minimal, but the write tool still sends toolCall.input.reasoningEffort ?? "low" in useWriteTool (apps/web/src/ai/tools/write/client.ts), so callers that rely on the schema contract will actually run at a higher effort than documented. This mismatch was introduced in this commit and can skew latency/cost and tool-selection behavior from the model.

Useful? React with 👍 / 👎.

),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ export function AppSidebarPageItemSkeleton({
return (
<SidebarMenuSubItem className={className}>
<div className="relative py-1">
<SidebarMenuSubButton
asChild
className="min-h-7 rounded-md"
>
<SidebarMenuSubButton asChild className="min-h-7 rounded-md">
<div className="group/page-item flex items-center hover:bg-transparent">
<Skeleton className="h-7 w-full rounded-md" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ import {
useSidebar,
} from "~/components/ui/sidebar";
import { cn } from "~/lib/cn";
import {
moveNode as moveTreeNode,
type QuerySnapshot,
restoreQueries,
snapshotQueries,
updateNode,
} from "~/trpc/cache/tree-cache";
import {
TREE_INSIDE_DROP_ZONE_CLASSNAME,
TREE_REORDER_AFTER_BAND_CLASSNAME,
Expand All @@ -69,6 +62,13 @@ import {
TreeDragOverlay,
treeCollisionDetection,
} from "~/lib/tree-dnd";
import {
moveNode as moveTreeNode,
type QuerySnapshot,
restoreQueries,
snapshotQueries,
updateNode,
} from "~/trpc/cache/tree-cache";
import { getInfiniteSidebarTreeQueryOptions } from "~/trpc/options/sidebar-tree-query-options";
import { useTRPC } from "~/trpc/react";
import { AppSidebarPageItem } from "./app-sidebar-page-item";
Expand Down Expand Up @@ -682,7 +682,9 @@ function DraggableFolderRow({
className={cn(
"min-h-7 rounded-md",
"group/folder-navigation relative z-10 flex min-w-0 items-center gap-0.5",
isOverInside && isDragActive && "bg-primary/20 ring-1 ring-primary/30",
isOverInside &&
isDragActive &&
"bg-primary/20 ring-1 ring-primary/30",
)}
>
<SidebarMenuSubButton
Expand Down Expand Up @@ -1319,7 +1321,7 @@ export const AppSidebarPages = ({
<SidebarTreeInteractionsContext.Provider
value={{ shouldSuppressClick }}
>
<SidebarMenuSub className="mx-0 mr-0 flex-1 gap-0 overflow-y-scroll overflow-x-clip border-none px-0">
<SidebarMenuSub className="mx-0 mr-0 flex-1 gap-0 overflow-x-clip overflow-y-scroll border-none px-0">
<SidebarTree
activeDragId={activeDragId}
isDnDEnabled={isDnDEnabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,7 @@ function DraggablePageRow({
onOpenChange={setIsDeleteDialogOpen}
>
<div className={itemIndentClassName}>
<div
ref={setNodeRef}
className="relative py-1"
>
<div ref={setNodeRef} className="relative py-1">
<FolderTreeInsertDropBands
activeDragId={activeDragId}
afterSiblingDropId={
Expand Down Expand Up @@ -946,7 +943,9 @@ function DraggableFolderRow({
"group/folder-navigation relative z-10",
isActive && "bg-primary/5 ring-1 ring-primary/20",
activeDragId === draggableId && "opacity-60",
isOverInside && isDragActive && "bg-primary/20 ring-1 ring-primary/30",
isOverInside &&
isDragActive &&
"bg-primary/20 ring-1 ring-primary/30",
)}
>
{isEditing ? (
Expand Down
35 changes: 15 additions & 20 deletions apps/web/src/app/api/ai/blocknote/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,22 @@ export const maxDuration = 300; // Allow streaming responses up to 300 seconds

const MAX_THREAD_CONTEXT_MESSAGES = 24;

const zMessages = z.custom<Parameters<typeof injectDocumentStateMessages>[0]>(
(value) => Array.isArray(value),
"messages must be an array",
);

const zReasoningEffort = zWriteInput.def.shape.reasoningEffort.default("low");

const zToolDefinitions = z.custom<
Parameters<typeof toolDefinitionsToToolSet>[0]
>((value) => {
if (!isRecord(value)) {
return false;
}

return "applyDocumentOperations" in value;
}, "toolDefinitions must include applyDocumentOperations");

const zBlockNoteRequest = z.object({
messages: zMessages,
reasoningEffort: zReasoningEffort,
toolDefinitions: zToolDefinitions,
messages: z.custom<Parameters<typeof injectDocumentStateMessages>[0]>(
(value) => Array.isArray(value),
"messages must be an array",
),
reasoningEffort: zWriteInput.def.shape.reasoningEffort.default("minimal"),
toolDefinitions: z.custom<Parameters<typeof toolDefinitionsToToolSet>[0]>(
(value) => {
if (!isRecord(value)) {
return false;
}

return "applyDocumentOperations" in value;
},
"toolDefinitions must include applyDocumentOperations",
),
});

export type BlockNoteRequest = z.infer<typeof zBlockNoteRequest>;
Expand Down
Loading