Repository navigation
Conversation
…ck the line when the page it's in isn't shared
… Leave out once it's saved
… saved Leave out from a late list read
…or its run read and migration
This branch has not been deployed
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.
Problem
#10028 added the "Agent gets" line above Content's message box: the open page, "+ N more", and a list of everything else that goes with the next message. It shows what the agent gets, but people can't do anything about it. If the pages above a post, your own instructions, or your memory would steer a chat the wrong way, the only option is to edit them for every chat.
The line also says nothing when a page was shared with you without the page it sits in. The server's walk up the page tree stops at the first page you can't read, so the agent quietly gets no pages above, including any writing rules kept there, and nothing tells you.
#10028 left three smaller gaps:
Approach
Three lines in the list get a "Leave out" button, which applies to this chat only:
get-documentstop listing the pages above the open page, and say they were left out.AGENTS.mdand instruction files (Custom instructions in Settings) stop going with each message.A left-out line is struck through, reads "left out of this chat", and its button turns into "Restore", once the server has saved the change; the button is disabled until then. A list read still under way when the change saves is dropped, so it can't undo it. The folded line adds "· 1 left out". The open page itself and the workspace's instructions can't be left out; the workspace line's detail now says so. A new chat starts with nothing left out.
Memory preferences (
memory/INSTRUCTIONS.md) still go when memory is left out: they say what the agent may save, and the agent can still save memories in that chat. So "Your instructions" now means Custom instructions only. In #10028 it covered both.The choice is stored on the server per chat and per person, so it holds when the page reloads and applies to every message in that chat. It reuses Context X-Ray's per-chat directives table rather than adding one: a left-out item is an
evictrow with the segment idleave-out:<item>. X-Ray matches segments by their real ids, so these rows don't touch its own pins and evictions. When a message starts, the agent loads the chat's set once into the run context, and the prompt loader and Content's actions check it throughisContextLeftOut(item). If that read fails, the message goes with everything, as it did before, and a warning is logged.When the page it's in isn't shared with you, the list shows a locked "Pages it's in" line that reads "not read: one isn't shared with you", with no button, and the folded line adds an amber "· its pages not read". It never names the unshared page or who owns it.
get-documentand the screen snapshot report the same thing asparentNotShared, and the agent's instructions tell it to say so if rules up there might matter, without guessing what they say. This shows only when the page it's in can't be read. A shared folder inside someone's private space still lists the folder, with no warning, since that is normal. A page at the top of someone's private space doesn't warn either: it sits in their space, not in a page.To get this right, the walk up the page tree changed in two ways:
get-documentgave no path at all to any page shared out of someone's private space. Every page in a space also belongs to that space's Files collection, and the reader can't open the owner's, soget-documentskipped the walk. It now walks like the screen snapshot does, and both list a shared folder.The gaps from #10028:
?databaseId=in the URL), so the list and the agent agree.Separately,
context_directivesstored its timestamps asINTEGER, which is a 32-bit column on Postgres, while the store writes millisecond timestamps (Date.now()). Every write failed with "value out of range for type integer". That broke X-Ray's pin and evict on Postgres before this PR, and it broke Leave out in tests and in the local sandbox. A new migration widens both columns toBIGINTon Postgres, the same fix asagent_harness_sessionsgot earlier.What changed
Core (
@agent-native/core, minor changeset):agent/context-xray/leave-out.ts:isContextLeftOut(item), theleave-out:<item>segment ids, and the core itemspersonal-instructionsandmemory(inshared/context-xray.ts).isContextLeftOutis exported from@agent-native/core/serverfor apps.agent/context-xray/directives-store.ts:loadContextLeaveOutandsetContextLeaveOut.agent/context-xray/actions/context-leave-out-list.tsandcontext-leave-out-set.ts: actions only the person can call (agentTool: false), allowed when you own the chat or it doesn't exist yet, since the list can be used before the first message. They are registered wherever X-Ray's other actions are.agent/run-ownership.ts:callerOwnsOrMayStartThread.agent/context-xray/run-leave-out.ts,agent/production-agent.tsandserver/request-context.ts: load the chat's set into the run context once per message, before the prompt is built.server/agent-chat/prompt-resources.ts: skip personal instructions and the memory index and memory search when they are left out.agent/context-xray/migrations.ts: migration 1204, Postgres only, widenscreated_atandupdated_attoBIGINT. The store migrations lock and schema snapshot are regenerated.Content:
server/lib/document-context.ts:readDocumentContextPathreturns the path and whether the page it's in couldn't be read. The walk ends at the first page it can't read, and a space's Files collection never counts as the page it's in.actions/view-screen.tsandactions/get-document.ts: drop the pages above when they're left out (only for the page on screen) and reportpagesAboveLeftOutorparentNotShared.view-screenpasses the collection from navigation.get-documentno longer skips the walk for a page whose collection you can't open.actions/_database-utils.ts: a collection open on screen drops its own path when the pages above are left out, soview-screen's collection section andget-content-databaseagree with the page.view-screensays the collection is on screen rather than letting it read navigation a second time, which could find another page if you moved on mid-read.app/hooks/use-navigation-state.ts: navigation state carriesdatabaseId.app/components/layout/AgentContextLine.tsxandagent-context-line.ts: the buttons, struck lines, the locked line, the folded counts, fold on send, and Escape.server/plugins/agent-chat.ts: two sentences in the agent's instructions aboutpagesAboveLeftOutandparentNotShared.app/agent-context-messages.ts: the new copy in all 11 locales.Safety and operations
ALTER COLUMN ... TYPE BIGINTrewritescontext_directivesunder a lock. The table holds only X-Ray directives, and every write to it has failed on Postgres until now, so it should be empty or close to it. SQLite doesn't run it; itsINTEGERalready holds 64-bit values. Rolling back the code leaves the wider columns, which older code reads fine.view-screenalready used. A parent you can open only through Content's space access for an organization other than your active one reads as not shared, so the lock can show for it.view-screen'sdatabaseMembershipstill gives the agent that collection's title, and both actions return the page's rawparentId. The line itself never names it.Verification
Checks on a cloud machine at this branch's commit:
leave-out.spec.ts(the actions, ownership, a chat that doesn't exist yet, the run context, and the prompt loader leaving each item out), and the schema snapshot specs. That spec failed against Postgres before the migration with the out-of-range error, and passes with it.run-leave-out.spec.ts), so the mutation check on changed Core lines runs on all of them: 92% of 143 mutants killed, against a 50% threshold. Those touched specs pass (13 files, 928 tests), along withintegrations/plugin.spec.ts, whose request-context mock now hasgetRequestRunContext, and the release-schema upgrade spec, which now expects migration 1204 to run as a step on an upgraded database.parentNotSharedonly when the page it's in can't be read,view-screenwith each item left out (including a collection on screen when you move on mid-read), navigation carrying the collection, and the component: Leave out showing only once saved, a list read from before it answering late, Restore, fold on a run but not on a failed send or a queued message, Escape in the editor folding before the panel sees it, and focus going back to the line. The collection read tests run too, sincegetContentDatabaseResponsechanged.view-screenread it, the line showed a change before it was saved, a list read from before a Leave out undid it, and a queued message folded the list.One CI check fails here and on
mainalike:default-catalog-preservationflags Clips, whose MCP connector catalog #9932 left implicit. #10246 fixes it.QA in a local Content sandbox (made-up pages, two local users) at the agent panel's real width (about 380px) and at a 390px phone width:
context-leave-out-setreturning["pages-above"]and the list reading it back, and the stored row has a millisecond timestamp.context-leave-out-setanswers, and the line takes the saved list from that answer without reading it again.get-documentfor that post returns an emptycontextPathwithparentNotShared: true.get-documentreturns[Recipes]. A page at the top of their space shows no warning either.Not covered in the browser: the sandbox can't connect a model, so the message box stays disabled. A real send, a failed send, and Escape pressed in the editor itself rely on the component tests. A page in two collections relies on the unit tests. What the agent receives with a real message needs checking on beta.
Review focus
leave-out:rows living beside X-Ray's own.get-documentnow walks the pages above for a page shared out of a collection or space you can't open, asview-screenalready did. It costs one ancestor query for those pages, and it lists only pages the reader can open. The walk's share check counts an organization share without rechecking that you're still in that organization; that isn't new, butget-documentnow reaches it for these pages.BIGINTmigration on existing Postgres databases.🤖 Generated with Claude Code