feat(agent): clarify create_file tool usage and context hint instructions

This commit is contained in:
yiling
2026-08-05 12:01:04 +08:00
parent 29161f3a1a
commit bb9c53adad
2 changed files with 10 additions and 7 deletions
+1 -1
View File
@@ -96,7 +96,7 @@ shumai has its own cloud file system. If a user asks you to perform file system
If you need to create files in the local filesystem (for example, a temporary file for uploading), only the '.pi' folder in the current directory has write permissions. Do NOT attempt to create files in any other directories.
When creating a file or version, first use 'list_autofill_fields' to inspect the project's AI-autofillable metadata fields. If relevant metadata depends on information unavailable from the file content (for example, the AI model or tool used to generate it), include a brief context hint (maximum 50 words) in the 'context' parameter.`
When creating a file or version, first use 'list_autofill_fields' to inspect the project's AI-autofillable metadata fields. If relevant metadata depends on information unavailable from the file content (for example, the AI model or tool used to generate it), include a brief context hint (maximum 50 words) in the 'context' field of 'create_file' or 'create_version' tool.`
if (agent.soul) {
systemPrompt = `${systemPrompt}\n\nAgent Personality and Core Instructions:\n${agent.soul}`
+9 -6
View File
@@ -1,12 +1,12 @@
import { Type } from '@sinclair/typebox'
import { type AgentTool } from '@earendil-works/pi-agent-core'
import { executeAgentToolWorkflow } from './utils'
import * as fs from 'fs'
import * as path from 'path'
import { s3Service } from '@shumai/core/src/s3/s3'
import { getFileMimeType, readFileMimeType } from '@shumai/core/src/utils/file-mime'
import { ulid } from 'ulid'
import { sanitizeFilename } from '@shumai/core/src/utils/filename'
import { Type } from '@sinclair/typebox'
import * as fs from 'fs'
import * as path from 'path'
import { ulid } from 'ulid'
import { executeAgentToolWorkflow } from './utils'
const createFileSchema = Type.Object({
parent: Type.String({
@@ -57,7 +57,10 @@ export function createCreateFileTool(userId: string): AgentTool<typeof createFil
name: 'create_file',
label: 'Create File',
description:
'Create a new file in a specified parent folder, either from a local file path or directly from name and content.',
'Create a new file under a folder. You MUST choose exactly ONE creation method: ' +
'(1) provide "path" to upload an existing local file, OR ' +
'(2) provide "data" with name and content to create a new text file. ' +
'Never provide both "path" and "data" together. Never omit both.',
parameters: createFileSchema,
execute: async (_toolCallId, params) => {
const source = assertExactlyOneSource(params)