LLMs having problems with optional array arguments #8167

Open
opened 2026-02-16 18:09:19 -05:00 by yindo · 3 comments
Owner

Originally created by @MBanucu on GitHub (Jan 31, 2026).

Originally assigned to: @fwang on GitHub.

Description

Grok Code Fast 1 is having issues with optional arrays. GPT-4.1 is not having this issue.

Plugins

opencode-pty

OpenCode version

1.1.47-f834915

Steps to reproduce

No response

Screenshot and/or share link

optional array

browser

page 1.png

Image

page 2.png

Image

page 3.png

Image

page 4.png

Image

page 5.png

Image

terminal

Image

session transcript

optional array - Run echo helllo world.md

source code

import { tool } from '@opencode-ai/plugin'
import { manager } from '../manager.ts'
import { checkCommandPermission, checkWorkdirPermission } from '../permissions.ts'
import DESCRIPTION from './spawn.txt'

export const ptySpawn = tool({
  description: DESCRIPTION,
  args: {
    command: tool.schema.string().describe('The command/executable to run'),
    args: tool.schema
      .array(tool.schema.string())
      .optional()
      .describe('Arguments to pass to the command'),
    workdir: tool.schema.string().optional().describe('Working directory for the PTY session'),
    env: tool.schema
      .record(tool.schema.string(), tool.schema.string())
      .optional()
      .describe('Additional environment variables'),
    title: tool.schema.string().optional().describe('Human-readable title for the session'),
    description: tool.schema
      .string()
      .describe('Clear, concise description of what this PTY session is for in 5-10 words'),
    notifyOnExit: tool.schema
      .boolean()
      .optional()
      .describe(
        'If true, sends a notification to the session when the process exits (default: false)'
      ),
  },
  async execute(args, ctx) {
    await checkCommandPermission(args.command, args.args ?? [])

    if (args.workdir) {
      await checkWorkdirPermission(args.workdir)
    }

    const sessionId = ctx.sessionID
    const info = manager.spawn({
      command: args.command,
      args: args.args,
      workdir: args.workdir,
      env: args.env,
      title: args.title,
      description: args.description,
      parentSessionId: sessionId,
      notifyOnExit: args.notifyOnExit,
    })

    const output = [
      `<pty_spawned>`,
      `ID: ${info.id}`,
      `Title: ${info.title}`,
      `Command: ${info.command} ${info.args.join(' ')}`,
      `Workdir: ${info.workdir}`,
      `PID: ${info.pid}`,
      `Status: ${info.status}`,
      `</pty_spawned>`,
    ].join('\n')

    return output
  },
})

required array

browser

page 1

Image

page 2

Image

terminal

Image

session transcript

required array - Run echo helllo world.md

source code

import { tool } from '@opencode-ai/plugin'
import { manager } from '../manager.ts'
import { checkCommandPermission, checkWorkdirPermission } from '../permissions.ts'
import DESCRIPTION from './spawn.txt'

export const ptySpawn = tool({
  description: DESCRIPTION,
  args: {
    command: tool.schema.string().describe('The command/executable to run'),
    args: tool.schema
      .array(tool.schema.string())
      // .optional()
      .describe('Arguments to pass to the command'),
    workdir: tool.schema.string().optional().describe('Working directory for the PTY session'),
    env: tool.schema
      .record(tool.schema.string(), tool.schema.string())
      .optional()
      .describe('Additional environment variables'),
    title: tool.schema.string().optional().describe('Human-readable title for the session'),
    description: tool.schema
      .string()
      .describe('Clear, concise description of what this PTY session is for in 5-10 words'),
    notifyOnExit: tool.schema
      .boolean()
      .optional()
      .describe(
        'If true, sends a notification to the session when the process exits (default: false)'
      ),
  },
  async execute(args, ctx) {
    await checkCommandPermission(args.command, args.args ?? [])

    if (args.workdir) {
      await checkWorkdirPermission(args.workdir)
    }

    const sessionId = ctx.sessionID
    const info = manager.spawn({
      command: args.command,
      args: args.args,
      workdir: args.workdir,
      env: args.env,
      title: args.title,
      description: args.description,
      parentSessionId: sessionId,
      notifyOnExit: args.notifyOnExit,
    })

    const output = [
      `<pty_spawned>`,
      `ID: ${info.id}`,
      `Title: ${info.title}`,
      `Command: ${info.command} ${info.args.join(' ')}`,
      `Workdir: ${info.workdir}`,
      `PID: ${info.pid}`,
      `Status: ${info.status}`,
      `</pty_spawned>`,
    ].join('\n')

    return output
  },
})

Operating System

NixOS 25.11

Terminal

kgx

Originally created by @MBanucu on GitHub (Jan 31, 2026). Originally assigned to: @fwang on GitHub. ### Description Grok Code Fast 1 is having issues with optional arrays. GPT-4.1 is not having this issue. ### Plugins opencode-pty ### OpenCode version 1.1.47-f834915 ### Steps to reproduce _No response_ ### Screenshot and/or share link # optional array ## browser ### page 1.png <img width="2880" height="1920" alt="Image" src="https://github.com/user-attachments/assets/787d1035-c0ac-4a9d-9d2a-e5fdb8087d9c" /> ### page 2.png <img width="2880" height="1920" alt="Image" src="https://github.com/user-attachments/assets/f83e30fd-0087-4665-8ebb-a3eb74486ac1" /> ### page 3.png <img width="2880" height="1920" alt="Image" src="https://github.com/user-attachments/assets/3b682690-9f12-424a-abfe-3db4200776c7" /> ### page 4.png <img width="2880" height="1920" alt="Image" src="https://github.com/user-attachments/assets/a8e90a24-5e87-42ba-a876-c50dafe9bccb" /> ### page 5.png <img width="2880" height="1920" alt="Image" src="https://github.com/user-attachments/assets/6da3afc5-ad46-4656-a39c-b84a79e90567" /> ## terminal <img width="2880" height="1920" alt="Image" src="https://github.com/user-attachments/assets/86d5ff36-48f4-493f-b79c-06339c231361" /> ## session transcript [optional array - Run echo helllo world.md](https://github.com/user-attachments/files/24984498/optional.array.-.Run.echo.helllo.world.md) ## source code ```ts import { tool } from '@opencode-ai/plugin' import { manager } from '../manager.ts' import { checkCommandPermission, checkWorkdirPermission } from '../permissions.ts' import DESCRIPTION from './spawn.txt' export const ptySpawn = tool({ description: DESCRIPTION, args: { command: tool.schema.string().describe('The command/executable to run'), args: tool.schema .array(tool.schema.string()) .optional() .describe('Arguments to pass to the command'), workdir: tool.schema.string().optional().describe('Working directory for the PTY session'), env: tool.schema .record(tool.schema.string(), tool.schema.string()) .optional() .describe('Additional environment variables'), title: tool.schema.string().optional().describe('Human-readable title for the session'), description: tool.schema .string() .describe('Clear, concise description of what this PTY session is for in 5-10 words'), notifyOnExit: tool.schema .boolean() .optional() .describe( 'If true, sends a notification to the session when the process exits (default: false)' ), }, async execute(args, ctx) { await checkCommandPermission(args.command, args.args ?? []) if (args.workdir) { await checkWorkdirPermission(args.workdir) } const sessionId = ctx.sessionID const info = manager.spawn({ command: args.command, args: args.args, workdir: args.workdir, env: args.env, title: args.title, description: args.description, parentSessionId: sessionId, notifyOnExit: args.notifyOnExit, }) const output = [ `<pty_spawned>`, `ID: ${info.id}`, `Title: ${info.title}`, `Command: ${info.command} ${info.args.join(' ')}`, `Workdir: ${info.workdir}`, `PID: ${info.pid}`, `Status: ${info.status}`, `</pty_spawned>`, ].join('\n') return output }, }) ``` # required array ## browser ### page 1 <img width="2880" height="1920" alt="Image" src="https://github.com/user-attachments/assets/30a5aa60-6d4c-4882-b21d-1a3e4e344993" /> ### page 2 <img width="2880" height="1920" alt="Image" src="https://github.com/user-attachments/assets/2af179e9-1c92-46f2-bf30-9e33be303071" /> ## terminal <img width="2880" height="1920" alt="Image" src="https://github.com/user-attachments/assets/94bfe030-903d-4759-bec7-e3fff668acf2" /> ## session transcript [required array - Run echo helllo world.md](https://github.com/user-attachments/files/24984499/required.array.-.Run.echo.helllo.world.md) ## source code ```ts import { tool } from '@opencode-ai/plugin' import { manager } from '../manager.ts' import { checkCommandPermission, checkWorkdirPermission } from '../permissions.ts' import DESCRIPTION from './spawn.txt' export const ptySpawn = tool({ description: DESCRIPTION, args: { command: tool.schema.string().describe('The command/executable to run'), args: tool.schema .array(tool.schema.string()) // .optional() .describe('Arguments to pass to the command'), workdir: tool.schema.string().optional().describe('Working directory for the PTY session'), env: tool.schema .record(tool.schema.string(), tool.schema.string()) .optional() .describe('Additional environment variables'), title: tool.schema.string().optional().describe('Human-readable title for the session'), description: tool.schema .string() .describe('Clear, concise description of what this PTY session is for in 5-10 words'), notifyOnExit: tool.schema .boolean() .optional() .describe( 'If true, sends a notification to the session when the process exits (default: false)' ), }, async execute(args, ctx) { await checkCommandPermission(args.command, args.args ?? []) if (args.workdir) { await checkWorkdirPermission(args.workdir) } const sessionId = ctx.sessionID const info = manager.spawn({ command: args.command, args: args.args, workdir: args.workdir, env: args.env, title: args.title, description: args.description, parentSessionId: sessionId, notifyOnExit: args.notifyOnExit, }) const output = [ `<pty_spawned>`, `ID: ${info.id}`, `Title: ${info.title}`, `Command: ${info.command} ${info.args.join(' ')}`, `Workdir: ${info.workdir}`, `PID: ${info.pid}`, `Status: ${info.status}`, `</pty_spawned>`, ].join('\n') return output }, }) ``` ### Operating System NixOS 25.11 ### Terminal kgx
Author
Owner

@github-actions[bot] commented on GitHub (Jan 31, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #4313: Edit Tool issues with Grok Code Fast 1 (same model)
  • #7512: Tools with array/object parameters fail when LLM sends stringified JSON
  • #8184: Strict JSON Schema validation fail on backends like SGLang (Missing required field in empty tool parameters)
  • #9233: LiteLLM Proxy: Vertex AI Gemini models fail for tools with empty parameters
  • #11357: JSON Schema validation fails on empty tool parameters {} with Kimi K2.5

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 31, 2026): This issue might be a duplicate of existing issues. Please check: - #4313: Edit Tool issues with Grok Code Fast 1 (same model) - #7512: Tools with array/object parameters fail when LLM sends stringified JSON - #8184: Strict JSON Schema validation fail on backends like SGLang (Missing required field in empty tool parameters) - #9233: LiteLLM Proxy: Vertex AI Gemini models fail for tools with empty parameters - #11357: JSON Schema validation fails on empty tool parameters {} with Kimi K2.5 Feel free to ignore if none of these address your specific case.
Author
Owner

@calebtt commented on GitHub (Jan 31, 2026):

If the problem is optional array arguments can you just edit a markdown file for the agent to tell it to always include the optional arguments?

@calebtt commented on GitHub (Jan 31, 2026): If the problem is optional array arguments can you just edit a markdown file for the agent to tell it to always include the optional arguments?
Author
Owner

@MBanucu commented on GitHub (Feb 1, 2026):

https://github.com/anomalyco/opencode/issues/11510#issuecomment-3829901042
If the problem is optional array arguments can you just edit a markdown file for the agent to tell it to always include the optional arguments?

It is easier to remove the optionality of the array and make it required as a workaround. The AI is automatically creating an empty array when no arguments should be specified. But this is a workaround, not a long term solution. Maybe the long term solution is to ditch grok code and move on in live. I feel like grok code is the worst coding agent I know of.

@MBanucu commented on GitHub (Feb 1, 2026): > [https://github.com/anomalyco/opencode/issues/11510#issuecomment-3829901042](https://github.com/anomalyco/opencode/issues/11510#issuecomment-3829901042) > If the problem is optional array arguments can you just edit a markdown file for the agent to tell it to always include the optional arguments? It is easier to remove the optionality of the array and make it required as a workaround. The AI is automatically creating an empty array when no arguments should be specified. But this is a workaround, not a long term solution. Maybe the long term solution is to ditch grok code and move on in live. I feel like grok code is the worst coding agent I know of.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8167