Folders on chat: chat(folder_id=) and folder_context() - #499
Merged
Conversation
The managed /chat/completions already takes folder_id and renders a folder targeting block ahead of the document block (pageindex-compute api.py:491, :3182); the SDK had no way to send it, and own-model chat had no folder analogue of document_context(). Both land here. folder_context(folder_id) renders that block as the managed chat renders its own: the name, an id/name/description metadata row (the server's FolderContext), and the directive to discover the folder's documents with browse_documents / search_documents(folder_id=..., recursive=true). One list_folders() call picks the folder by id: the endpoint has no LIMIT and lists the same userId + api_surface partition the managed chat validates against, so what the helper finds is what the server accepts, and it carries the same plan gate, so a non-Max key fails here rather than mid-run. A missing folder raises. Cloud-only: local libraries have no folders. chat(folder_id=) places it. The managed lane sends the field and lets the server render and gate it; the three own-model lanes lead the conversation with one user message, folder block then document block, joined as the server joins them. folder_id joins the prompt-cache key for the reason doc_id does: the block is byte-identical for every conversation about a folder. "root" (and "") targets nothing on every lane and in every mode, as the server treats folder_id="root": folder_context returns "" and chat places nothing. folder_id is keyword-only on chat() and trailing on every other signature, so no positional call shifts. Tests: the wire field on the managed lane; block order and root/"" on the shared renderer; folder_id threaded through the chat, responses and messages engines; the local cloud-only refusal. Claude-Session: https://claude.ai/code/session_01NsQjN5HMmmX4n5NVsZWYaw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #495 (base
feat/document-context); merge after it.What
client.folder_context(folder_id): the folder targeting text for the first user message, the folder analogue ofdocument_context().chat(folder_id=), also onchat_completions()and theresponses/messagesprotocol lanes: places it, or on the managed lane sends the field the server already accepts.Wire truth
/chat/completionstakesfolder_id(ChatCompletionRequest.folder_id, pageindex-computeserver/api/api.py:491) and renders "The user has specified folder: ..." ahead of the document block (api.py:3182); the metadata row is the server'sFolderContext: id, name, description (server/lib/db/folders.py:50). The SDK renders the same text./folders/lists the same partition the chat validates against (userId+api_surface_sql, no LIMIT), so what the helper finds is what the server accepts; it carriesrequire_folder_plan, so a non-Max key fails at the helper, not mid-run.Decisions
"root"(and"") is the library itself:folder_contextreturns"",chatplaces nothing, on every lane and in every mode, as the server treatsfolder_id="root".folder_idjoins the prompt-cache key, for the reasondoc_iddoes.chat(), trailing on every other signature: no positional call shifts.create_folder/list_folders.Verification
chat(q, folder_id=F)lists the folder's documents;folder_id="root"answers normally; own-model over cloud tools callsbrowse_documents(folder_id=F, recursive=true)first and gives the same list.Docs: VectifyAI/pageindex-docs#53.
https://claude.ai/code/session_01NsQjN5HMmmX4n5NVsZWYaw