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). */
| 146 | * Matches the JSON forms "key":N / \"key\":N and the TOON scalar `key: N` |
| 147 | * (search_graph default output since the compact-output change). */ |
| 148 | static int count_in_response(const char *resp, const char *key) { |
| 149 | if (!resp) |
| 150 | return -1; |
| 151 | char pattern[64]; |
| 152 | snprintf(pattern, sizeof(pattern), "\"%s\":", key); |
| 153 | const char *p = strstr(resp, pattern); |
| 154 | if (p) |
| 155 | return atoi(p + strlen(pattern)); |
| 156 | snprintf(pattern, sizeof(pattern), "\\\"%s\\\":", key); |
| 157 | p = strstr(resp, pattern); |
| 158 | if (p) |
| 159 | return atoi(p + strlen(pattern)); |
| 160 | snprintf(pattern, sizeof(pattern), "%s: ", key); |
| 161 | p = strstr(resp, pattern); |
| 162 | if (p) |
| 163 | return atoi(p + strlen(pattern)); |
| 164 | return -1; |
| 165 | } |
| 166 | |
| 167 | /* ── Direct store queries (more reliable than MCP for tests) ────── */ |
| 168 |
no outgoing calls
no test coverage detected