openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Composio Gmail search returns no results because agents call actions before seeing the full parameter schema

Open yh928 opened this issue 4 months ago • 1 comments

Summary

When an agent uses the Composio GMAIL_FETCH_EMAILS action, it frequently composes the query argument without the quoting that Gmail search syntax requires, so the search returns zero results. Related symptom: the agent sometimes calls a non-existent action slug (e.g. GMAIL_LIST_MESSAGES, a raw Gmail-API-style name) instead of the real GMAIL_FETCH_EMAILS.

Problem

What happens vs. expected. Asking the agent to search/list Gmail messages often returns nothing. Inspecting the tool call shows the query sent to GMAIL_FETCH_EMAILS lacks the quotes Gmail needs for phrase / multi-term searches (e.g. subject:"quarterly report"). Separately, the model sometimes invokes an action that does not exist (GMAIL_LIST_MESSAGES) rather than the real slug. Expected: the agent calls the correct action with a well-formed query and gets results.

Steps to reproduce (minimal).

  1. Connect the Gmail toolkit via Composio.
  2. Ask the agent to search Gmail for a multi-word phrase (e.g. emails whose subject contains a phrase).
  3. Observe: 0 results; the tool call's query omits quotes — or the agent calls a slug like GMAIL_LIST_MESSAGES that isn't in the toolkit.

Diagnostic that points at the cause. Telling the agent to run composio_list_tools / read the tool contract first makes it quote correctly and use the right slug — because only then does the action's real parameter schema/description enter the model's context.

Version / platform. Dev build, openhuman-core (Linux), Composio Gmail integration (backend mode).

Solution (optional)

Root cause. The per-action Composio tools handed to integrations_agent are built from the lightweight list_tools response — a one-line description with parameters that can be None (see fetch_toolkit_actions in src/openhuman/composio/connected_integrations.rs, consumed in src/openhuman/agent/harness/subagent_runner/ops/runner.rs) — not the full contract available via get_tool_contract / fetch_live_toolkit_catalog (src/openhuman/flows/builder_tools.rs, src/openhuman/tinyflows/caps.rs). The generic composio_execute dispatcher's arguments is an opaque {"type":"object"} (src/openhuman/composio/tools.rs). So the model composes calls before the full schema/description is in context, and guesses argument formats and slugs.

The same thin-list-vs-full-contract split exists on other late-bound surfaces: MCP tools (mcp_call_tool, mcp_registry_tool_call + their *_list_tools discovery meta-tools) and Workflows (run_workflow + describe_workflow).

Proposed fix. Gate late-bound tool dispatch on the contract: when the model calls one of these actions/dispatchers for a target whose full contract it has not seen this turn, short-circuit execution and return a tool error carrying that target's full contract (input schema + description; or "no such action" + the valid list when the id is unknown). The retry — now with the contract in context — executes normally. Reset the per-turn "seen contract" state on context compaction so the contract is re-surfaced if it was summarized away. Apply uniformly to Composio, MCP (both bridges), and Workflows.

Acceptance criteria

  • [ ] Repro gone — the agent searches Gmail via Composio and returns results without being told to read the contract first, and no longer invents slugs like GMAIL_LIST_MESSAGES.
  • [ ] Regression safety — unit coverage for the gate: first call returns the contract, the retry executes, an unknown id yields a not-found + valid list, and compaction resets the per-turn state.
  • [ ] Diff coverage ≥ 80% — the fix PR meets the changed-lines coverage gate.
  • [ ] Generalized — the gate covers the MCP and Workflow dispatchers too, not only Composio.

Related

  • Root-cause code: src/openhuman/agent/harness/subagent_runner/ops/runner.rs, src/openhuman/composio/connected_integrations.rs (fetch_toolkit_actions), src/openhuman/composio/tools.rs (composio_execute), src/openhuman/flows/builder_tools.rs (get_tool_contract), src/openhuman/tinyflows/caps.rs (fetch_live_toolkit_catalog).
  • Fix PR: to be linked.

yh928 avatar Jul 14 '26 09:07 yh928

thanks @yh928 reviewing and patching this

senamakel avatar Jul 14 '26 09:07 senamakel