Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(mcp-host): say that gfs stat, resolve and list report the live version

Alfredo Lopezd443483c31e0
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 4b9125622..320151276 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.455",
+ "version": "0.1.456",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.455",
+ "version": "0.1.456",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index ab5f7752e..8098d7bc2 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.455",
+ "version": "0.1.456",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/core/orchestration/__tests__/turnContext.test.ts b/mcp-host/src/core/orchestration/__tests__/turnContext.test.ts
index 3edb62e8d..a7d7de7e1 100644
--- a/mcp-host/src/core/orchestration/__tests__/turnContext.test.ts
+++ b/mcp-host/src/core/orchestration/__tests__/turnContext.test.ts
@@ -306,11 +306,11 @@ describe('referenced_file lines (issue #666)', () => {
'referenced_file: id="gfs:main:0000000000000000000000000000000a@v3" name="plan.md" source=gfs drive="main" resourceId="0000000000000000000000000000000a" version=3 class=markdown bytes=120 availability=available\n' +
'referenced_file: id="gfs:main:0000000000000000000000000000000b@v1" name="old.md" source=gfs drive="main" resourceId="0000000000000000000000000000000b" version=1 class=markdown bytes=120 availability=stale code=FILE_REFERENCE_STALE current_version=4\n' +
`referenced_file: id="att:message-0:file-9@sha256:${'c'.repeat(64)}" name="earlier.txt" source=attachment class=text bytes=8 availability=unsupported code=FILE_REFERENCE_UNSUPPORTED\n` +
- "If the user's request refers to a referenced file, read it with clerum__gfs_read using its drive and resourceId. The Host pins each referenced file to its listed version; pass expectedVersion only to read the current_version of a stale reference. A referenced file whose availability is neither available nor stale cannot be read in this turn; tell the user why instead of guessing.\n" +
+ "If the user's request refers to a referenced file, read it with clerum__gfs_read using its drive and resourceId. The Host pins each referenced file to its listed version; pass expectedVersion only to read the current_version of a stale reference. clerum__gfs_stat, clerum__gfs_resolve and clerum__gfs_list report the live file, so their version can be newer than the one listed here; clerum__gfs_read still reads the listed version, and a newer one is not readable in this turn unless the reference is stale. A referenced file whose availability is neither available nor stale cannot be read in this turn; tell the user why instead of guessing.\n" +
'</turn-context>\n\n'
)
expect(REFERENCED_FILES_INSTRUCTION).toBe(
- "If the user's request refers to a referenced file, read it with clerum__gfs_read using its drive and resourceId. The Host pins each referenced file to its listed version; pass expectedVersion only to read the current_version of a stale reference. A referenced file whose availability is neither available nor stale cannot be read in this turn; tell the user why instead of guessing."
+ "If the user's request refers to a referenced file, read it with clerum__gfs_read using its drive and resourceId. The Host pins each referenced file to its listed version; pass expectedVersion only to read the current_version of a stale reference. clerum__gfs_stat, clerum__gfs_resolve and clerum__gfs_list report the live file, so their version can be newer than the one listed here; clerum__gfs_read still reads the listed version, and a newer one is not readable in this turn unless the reference is stale. A referenced file whose availability is neither available nor stale cannot be read in this turn; tell the user why instead of guessing."
)
})
diff --git a/mcp-host/src/core/orchestration/turnContext.ts b/mcp-host/src/core/orchestration/turnContext.ts
index e55cceab6..5a75557df 100644
--- a/mcp-host/src/core/orchestration/turnContext.ts
+++ b/mcp-host/src/core/orchestration/turnContext.ts
@@ -80,7 +80,7 @@ export const ATTACHED_FILES_INSTRUCTION =
"If the user's request refers to an attached file, read it with clerum__attachment_read before answering. Files with reader=none cannot be read in this turn; say so instead of guessing."
export const REFERENCED_FILES_INSTRUCTION =
- "If the user's request refers to a referenced file, read it with clerum__gfs_read using its drive and resourceId. The Host pins each referenced file to its listed version; pass expectedVersion only to read the current_version of a stale reference. A referenced file whose availability is neither available nor stale cannot be read in this turn; tell the user why instead of guessing."
+ "If the user's request refers to a referenced file, read it with clerum__gfs_read using its drive and resourceId. The Host pins each referenced file to its listed version; pass expectedVersion only to read the current_version of a stale reference. clerum__gfs_stat, clerum__gfs_resolve and clerum__gfs_list report the live file, so their version can be newer than the one listed here; clerum__gfs_read still reads the listed version, and a newer one is not readable in this turn unless the reference is stale. A referenced file whose availability is neither available nor stale cannot be read in this turn; tell the user why instead of guessing."
// Client-supplied values are written with quotePromptValue, which keeps each
// one on its own line and inside its own field. Values the Host computed
diff --git a/mcp-host/src/internalTools/gfs.expectedVersion.test.ts b/mcp-host/src/internalTools/gfs.expectedVersion.test.ts
index 60bc08d71..1a347224c 100644
--- a/mcp-host/src/internalTools/gfs.expectedVersion.test.ts
+++ b/mcp-host/src/internalTools/gfs.expectedVersion.test.ts
@@ -54,7 +54,7 @@ function harness(
)!
const contentRequests = () =>
request.mock.calls.filter(([path]) => path.includes('/content?')).length
- return { tool, read, request, contentRequests }
+ return { client, referencedFiles, tool, read, request, contentRequests }
}
describe('clerum__gfs_read expectedVersion (#666)', () => {
@@ -230,6 +230,31 @@ describe('clerum__gfs_read pinned by a file reference of the message (#666)', ()
expect(read).not.toHaveBeenCalled()
})
+ it('lets stat report a newer live version and still reads the referenced one', async () => {
+ const { client, referencedFiles, tool, read } = harness(3, 3, pinned(3))
+ vi.mocked(client.stat).mockResolvedValue({
+ resourceId: FILE_ID,
+ drive: 'main',
+ gfsUri: FILE_URI,
+ kind: 'file',
+ name: 'notes.txt',
+ version: 4,
+ bytes: SENTINEL.length,
+ } as Awaited<ReturnType<GfscReadClient['stat']>>)
+ const stat = buildGfsReadTools(client, { referencedFiles }).find(
+ t => t.name === 'clerum__gfs_stat'
+ )!
+
+ const statResult = await stat.execute({ drive: 'main', resourceId: FILE_ID }, '')
+ expect(client.stat).toHaveBeenCalledTimes(1)
+ expect(JSON.parse(statResult.content as string)).toMatchObject({ version: 4 })
+
+ // Witness that stat left the pin intact: the read still asks for version 3.
+ await tool.execute({ drive: 'main', resourceId: FILE_ID }, '')
+ expect(read).toHaveBeenCalledTimes(1)
+ expect(read.mock.calls[0]![1]).toMatchObject({ expectedVersion: 3 })
+ })
+
it('leaves a file the message did not reference unpinned', async () => {
const other = new Map([[`main/${'e'.repeat(32)}`, { version: 9 }]])
const { tool, read } = harness(3, 3, other)
diff --git a/mcp-host/src/internalTools/gfs.ts b/mcp-host/src/internalTools/gfs.ts
index 0500492e6..4f939ec6e 100644
--- a/mcp-host/src/internalTools/gfs.ts
+++ b/mcp-host/src/internalTools/gfs.ts
@@ -148,6 +148,13 @@ function pinnedVersionMessage(pin: ReferencedFilePin): string {
: `${base}, or pass its current_version ${pin.currentVersion} to read the current file.`
}
+/**
+ * #666 — stat, resolve and list report the live resource, which can be newer
+ * than the version a referenced file is pinned to for clerum__gfs_read.
+ */
+const LIVE_RESOURCE_NOTE =
+ 'Reports the live resource; a file referenced in the current message is still read at its listed version.'
+
export interface GfsReadToolOptions {
/** Files the turn's message referenced; an empty map when there is no message. */
referencedFiles: ReferencedFilePins
@@ -190,7 +197,7 @@ export function buildGfsReadTools(
},
{
name: 'clerum__gfs_list',
- description: 'List the children of a gfs directory. Returns entries with their gfsUri.',
+ description: `List the children of a gfs directory. Returns entries with their gfsUri. ${LIVE_RESOURCE_NOTE}`,
parameters: {
type: 'object',
required: ['drive', 'resourceId'],
@@ -319,7 +326,7 @@ export function buildGfsReadTools(
},
{
name: 'clerum__gfs_stat',
- description: 'Stat a gfs resource (name, kind, version, bytes, gfsUri).',
+ description: `Stat a gfs resource (name, kind, version, bytes, gfsUri). ${LIVE_RESOURCE_NOTE}`,
parameters: driveResourceParams,
execute: async (
args: Record<string, unknown>,
@@ -337,7 +344,7 @@ export function buildGfsReadTools(
},
{
name: 'clerum__gfs_resolve',
- description: 'Resolve a gfs:// URI to its current resource + canonical path.',
+ description: `Resolve a gfs:// URI to its current resource + canonical path. ${LIVE_RESOURCE_NOTE}`,
parameters: {
type: 'object',
required: ['uri'],