Carry a denied Google tool call into a complete CometAPI tool transcript

A blocked tool call needs two outcomes: the tool does not run, and the model receives an accurate result for the call it requested. When moving a managed-agent workflow into a CometAPI application, preserving only the first outcome leaves the conversation unfinished.

Google’s managed-agent hooks article describes a pre_tool_execution gate: returning {"decision":"deny","reason":"..."} skips the tool and supplies the rejection reason to the model’s context. That is the behavior worth preserving—not the Google configuration file itself.

Put the denial at CometAPI’s tool-result boundary

The official CometAPI Chat Completions reference documents https://api.cometapi.com/v1 as the SDK base URL and uses gpt-5.6-sol for its function-calling example. Its continuation pattern is to parse the JSON-encoded function arguments, execute the function, and append the assistant message plus a role: "tool" result whose tool_call_id matches the original call.

For a policy-gated application, I would change the execution step, not the message linkage:

  1. Retain the original assistant message, including its tool calls and IDs.
  2. Parse and validate the requested function and arguments against application policy before invoking anything.
  3. Execute only an allowed call. For a denied call, do not invoke the function; construct a denial result instead.
  4. Append that result under the original call ID and include the assistant/result pair in the next Chat Completions request.

For example, suppose a declared write_file function receives a path that the application rejects, and the assistant’s call ID is target_c2. The proposed result message is:

{
  "role": "tool",
  "tool_call_id": "target_c2",
  "content": "{\"status\":\"denied\",\"reason\":\"path_not_allowed\"}"
}

Here, status and reason are application-defined data serialized inside content. They are not native CometAPI denial fields. The preceding assistant message must still contain the original target_c2 call; the result above is not a standalone replacement for that message.

This is an application-level adaptation of Google’s denial behavior using CometAPI’s documented transcript structure. It does not imply that CometAPI loads .agents/hooks.json or supplies Google’s hook runtime. Keep the model scope narrow, too: this reference uses gpt-5.6-sol for functions and directs GPT-6 Astra tool calling to Responses.

Test the transcript before testing a live tool

A useful acceptance fixture needs no real filesystem write. Supply one assistant write_file call with a deliberately disallowed path and a stub executor that counts invocations. Require all of the following:

  • The executor count remains zero.
  • The original assistant call remains in the transcript.
  • Exactly one denial result matches target_c2.
  • The next request’s messages include that assistant/result pair.

As negative cases, substitute a different result ID or put the denial only in an unrelated user message. Both should fail the fixture: neither preserves the requested call’s result linkage. If a turn contains several calls, account for each call before continuing; the single-call fixture is not a complete multi-call implementation.

These are proposed acceptance criteria, not reported test results. A complete transcript lets the model see the rejection; it does not prove that the model will respect it next time. Gate every subsequent call independently. As an application policy, stop side effects when parsing or policy evaluation fails, and expose a sanitized reason code rather than private paths or internal rule details. Google’s article does not establish the full timeout policy, and a post-tool check should not be treated as rollback.

The integration decision is therefore specific: keep authorization in the application, and carry its denial through CometAPI’s matching tool-result message. A prompt asking the model not to retry is not a substitute for that execution boundary.