Skip to content

Handle computer_call outputs that return actions[] instead of action#759

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-undefined-array-key-action
Draft

Handle computer_call outputs that return actions[] instead of action#759
Copilot wants to merge 3 commits intomainfrom
copilot/fix-undefined-array-key-action

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

OutputComputerToolCall::from() assumed a single action object, but real computer_call payloads may return actions (array), causing undefined key errors. This PR updates parsing to support both shapes and hardens behavior for missing/invalid action payloads.

  • Parser compatibility update

    • Accepts either:
      • action (existing behavior), or
      • actions[0] (new fallback for observed API payloads)
    • Preserves existing model output shape (toArray() still emits action).
  • Defensive handling for optional fields

    • Treats missing pending_safety_checks as an empty list.
    • Throws a clear InvalidArgumentException when no valid action payload is present.
  • Focused test coverage additions

    • Parses payloads with actions only.
    • Uses first element when multiple actions are present.
    • Verifies exceptions for empty/missing/malformed action payloads.
$actionAttributes = [];
if (isset($attributes['action'])) {
    $actionAttributes = $attributes['action'];
} elseif (isset($attributes['actions']) && isset($attributes['actions'][0])) {
    $actionAttributes = $attributes['actions'][0];
}

if (! isset($actionAttributes['type'])) {
    throw new \InvalidArgumentException('Missing required computer action payload.');
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/filp/whoops/zipball/d2102955e48b9fd9ab24280a7ad12ed552752c4d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/y3H2pq /usr/bin/composer install (http block)
  • https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/y3H2pq /usr/bin/composer install (http block)
  • https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/y3H2pq /usr/bin/composer install (http block)
  • https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/y3H2pq /usr/bin/composer install (http block)
  • https://api.github.com/repos/php-http/discovery/zipball/82fe4c73ef3363caed49ff8dd1539ba06044910d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/y3H2pq /usr/bin/composer install (http block)
  • https://api.github.com/repos/phpstan/phpstan/zipball/37982d6fc7cbb746dda7773530cda557cdf119e1
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/EwI9L5 /usr/bin/composer install --prefer-source --no-interaction (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/y3H2pq /usr/bin/composer install (http block)
  • https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/y3H2pq /usr/bin/composer install (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 2 commits April 15, 2026 19:59
Copilot AI changed the title [WIP] Fix undefined array key 'action' in OutputComputerToolCall Handle computer_call outputs that return actions[] instead of action Apr 15, 2026
Copilot AI requested a review from iBotPeaches April 15, 2026 20:02
@dking3876
Copy link
Copy Markdown

I don't think this will work as it can return multiple actions and this code only accounts for a single action $actionAttributes = $attributes['actions'][0];
It needs to loop throught he actions and return the full array of possible actions to take.
In addition there is TooObjects that need to be udpated to account for computer as a tool vs computer_use_preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Undefined array key 'action' for /Responses/Responses/Output/OutputComputerToolCall.php

3 participants