Skip to content

Commit fe11ca8

Browse files
committed
fix(prompt): guide agent to use service-specific APIs instead of Drive for content creation
The Drive SKILL.md example misleads LLMs into using `drive files create` for spreadsheets/docs, producing empty files. Add system prompt guidance to prefer sheets/docs/slides APIs for content operations.
1 parent d2a0564 commit fe11ca8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

agent/tools/prompt.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ The tool handles authentication, scope checks, and approval for write operations
8888
When a tool result includes "user notified", keep your response brief — the user already got the details.
8989
If a gws_execute call fails, read the error output carefully — it usually contains the correct syntax or hints. Fix the command and retry (up to 3 attempts) before giving up. Common fixes: wrong subcommand name, missing required params, wrong field names in body.
9090
If the error mentions "API has not been used" or "SERVICE_DISABLED", extract the activation URL from the error and share it with the user so they can enable the API.
91+
IMPORTANT: To create or edit Google Sheets, Docs, or Slides, always use the service-specific API (sheets, docs, slides), NOT the Drive API. For example, use "sheets spreadsheets create" to create a spreadsheet, "docs documents create" to create a document. The Drive API (drive files create) can only create empty file shells without content. Use Drive only for file management (list, move, copy, delete, share, permissions).
9192
`)
9293
}
9394

agent/tools/prompt_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ func TestBuildBaseSystemPrompt_WebInstructions(t *testing.T) {
5757
}
5858
}
5959

60+
func TestBuildBaseSystemPrompt_GWSServiceSpecificAPIGuidance(t *testing.T) {
61+
reg := NewRegistry()
62+
reg.Register(&stubTool{name: "gws_execute"})
63+
64+
prompt := BuildBaseSystemPrompt(reg)
65+
if !strings.Contains(prompt, "sheets spreadsheets create") {
66+
t.Error("expected guidance to use sheets API for spreadsheets")
67+
}
68+
if !strings.Contains(prompt, "docs documents create") {
69+
t.Error("expected guidance to use docs API for documents")
70+
}
71+
if !strings.Contains(prompt, "Drive API (drive files create) can only create empty file shells") {
72+
t.Error("expected warning about Drive API limitations")
73+
}
74+
}
75+
6076
func TestBuildBaseSystemPrompt_NoWebInstructions(t *testing.T) {
6177
reg := NewRegistry()
6278

0 commit comments

Comments
 (0)