refactor(windows): re-apply guidance with minimal formatting changes

Addresses feedback about formatting noise by reverting system-prompt.ts and re-applying logic minimally. PR template removed (moved to separate PR).
This commit is contained in:
Nathan Hangen 2026-01-28 19:33:13 -05:00
parent e3f4194e94
commit 38f91f875b
3 changed files with 113 additions and 95 deletions

View File

@ -14,6 +14,8 @@ describe("isFailoverErrorMessage", () => {
const samples = [ const samples = [
"invalid api key", "invalid api key",
"429 rate limit exceeded", "429 rate limit exceeded",
"No available auth profile for openai-codex (all in cooldown or unavailable).",
"Provider openai-codex is in cooldown (all profiles unavailable)",
"Your credit balance is too low", "Your credit balance is too low",
"request timed out", "request timed out",
"invalid request format", "invalid request format",

View File

@ -362,6 +362,10 @@ const ERROR_PATTERNS = {
"quota exceeded", "quota exceeded",
"resource_exhausted", "resource_exhausted",
"usage limit", "usage limit",
// Auth-profile selection can fail due to provider-wide cooldown after repeated rate limits.
// Treat as rate_limit so model fallback can engage even before a request is sent.
/all in cooldown/i,
/in cooldown \(all profiles unavailable\)/i,
], ],
overloaded: [/overloaded_error|"type"\s*:\s*"overloaded_error"/i, "overloaded"], overloaded: [/overloaded_error|"type"\s*:\s*"overloaded_error"/i, "overloaded"],
timeout: ["timeout", "timed out", "deadline exceeded", "context deadline exceeded"], timeout: ["timeout", "timed out", "deadline exceeded", "context deadline exceeded"],
@ -388,6 +392,8 @@ const ERROR_PATTERNS = {
/\b403\b/, /\b403\b/,
"no credentials found", "no credentials found",
"no api key found", "no api key found",
// Agent can fail before request if no usable auth profile exists.
/no available auth profile/i,
], ],
format: [ format: [
"string should match pattern", "string should match pattern",

View File

@ -399,6 +399,17 @@ export function buildAgentSystemPrompt(params: {
"Treat this directory as the single global workspace for file operations unless explicitly instructed otherwise.", "Treat this directory as the single global workspace for file operations unless explicitly instructed otherwise.",
...workspaceNotes, ...workspaceNotes,
"", "",
...(runtimeInfo?.os?.toLowerCase().includes("windows")
? [
"## Windows Shell Guidance",
"You are running on Windows (PowerShell).",
"- Use PowerShell syntax (e.g. `$env:VAR` instead of `%VAR%` or `$VAR`).",
"- Do NOT use Unix commands like `grep`, `sed`, `awk`, `head`, `tail` in exec/shell (PowerShell) commands unless you are sure they are installed. Pi's built-in tools named `grep`, `find`, and `ls` are safe to use.",
"- Use `findstr` or `Select-String` instead of `grep`.",
"- Use `Get-ChildItem` (dir/ls) with `-Recurse` instead of `find`.",
"",
]
: []),
...docsSection, ...docsSection,
params.sandboxInfo?.enabled ? "## Sandbox" : "", params.sandboxInfo?.enabled ? "## Sandbox" : "",
params.sandboxInfo?.enabled params.sandboxInfo?.enabled
@ -410,8 +421,7 @@ export function buildAgentSystemPrompt(params: {
? `Sandbox workspace: ${params.sandboxInfo.workspaceDir}` ? `Sandbox workspace: ${params.sandboxInfo.workspaceDir}`
: "", : "",
params.sandboxInfo.workspaceAccess params.sandboxInfo.workspaceAccess
? `Agent workspace access: ${params.sandboxInfo.workspaceAccess}${ ? `Agent workspace access: ${params.sandboxInfo.workspaceAccess}${params.sandboxInfo.agentWorkspaceMount
params.sandboxInfo.agentWorkspaceMount
? ` (mounted at ${params.sandboxInfo.agentWorkspaceMount})` ? ` (mounted at ${params.sandboxInfo.agentWorkspaceMount})`
: "" : ""
}` }`