Parse integer from a tool response (handles the nested MCP envelope). * Matches the JSON forms "key":N / \"key\":N and the TOON scalar `key: N` * (search_graph default output since the compact-output change). */
| 132 | * Matches the JSON forms "key":N / \"key\":N and the TOON scalar `key: N` |
| 133 | * (search_graph default output since the compact-output change). */ |
| 134 | static int count_in_response(const char *resp, const char *key) { |
| 135 | if (!resp) |
| 136 | return -1; |
| 137 | char pattern[64]; |
| 138 | snprintf(pattern, sizeof(pattern), "\"%s\":", key); |
| 139 | const char *p = strstr(resp, pattern); |
| 140 | if (p) |
| 141 | return atoi(p + strlen(pattern)); |
| 142 | snprintf(pattern, sizeof(pattern), "\\\"%s\\\":", key); |
| 143 | p = strstr(resp, pattern); |
| 144 | if (p) |
| 145 | return atoi(p + strlen(pattern)); |
| 146 | snprintf(pattern, sizeof(pattern), "%s: ", key); |
| 147 | p = strstr(resp, pattern); |
| 148 | if (p) |
| 149 | return atoi(p + strlen(pattern)); |
| 150 | return -1; |
| 151 | } |
| 152 | |
| 153 | /* ── Direct store queries (more reliable than MCP for tests) ────── */ |
| 154 |
no outgoing calls
no test coverage detected