Skip to content

Commit 4b30cd6

Browse files
committed
fix: update return values to reflect number of rows inserted in agent_run non table mode function and related tests/documentation
1 parent 6e0bd83 commit 4b30cd6

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ SELECT agent_run(goal, table_name, max_iterations, system_prompt);
5858
| `system_prompt` | TEXT | No | NULL | Custom system prompt |
5959

6060
**Returns:**
61-
- **MODE 1 (text):** TEXT – Agent's final response
62-
- **MODE 2 (table):** TEXTStatus message (e.g., "Inserted 5 rows into listings")
61+
- **MODE 1 (text):** TEXT – Agent's final response
62+
- **MODE 2 (table):** INTEGERNumber of rows inserted into the table
6363

6464
**MODE 1: Text Response**
6565

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ SELECT agent_run(
132132
'listings',
133133
8
134134
);
135-
-- Returns: "Inserted 5 rows into listings"
135+
-- Returns: 5 (number of rows inserted)
136136

137137
-- Semantic search (works immediately!)
138138
SELECT title, location, price, v.distance

USAGE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ SELECT agent_run(
195195
'listings',
196196
8
197197
);
198-
-- Returns: "Inserted 5 rows into listings"
198+
-- Returns: 5 (number of rows inserted)
199199

200200
-- 5. Semantic search (works immediately!)
201201
SELECT title, location, price, v.distance

src/sqlite-agent.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,10 +1021,7 @@ static void agent_run_func(
10211021
}
10221022

10231023
free(tools_list);
1024-
1025-
char result[256];
1026-
snprintf(result, sizeof(result), "Inserted %d rows into %s", rows_inserted, table_name);
1027-
sqlite3_result_text(context, result, -1, SQLITE_TRANSIENT);
1024+
sqlite3_result_int(context, rows_inserted);
10281025
}
10291026

10301027
#ifdef _WIN32

test/airbnb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ void* worker_thread(void* arg) {
196196
return NULL;
197197
}
198198

199-
const char *result = (const char *)sqlite3_column_text(stmt, 0);
200-
printf("\n * %s\n", result ? result : "Agent completed");
199+
int rows_inserted = sqlite3_column_int(stmt, 0);
200+
printf("\n * Inserted %d rows into listings\n", rows_inserted);
201201
sqlite3_finalize(stmt);
202202

203203
// Get listing count

test/github.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ int main(void) {
217217
return 1;
218218
}
219219

220-
const char *result = (const char *)sqlite3_column_text(stmt, 0);
221-
printf(" * %s\n", result ? result : "Agent completed");
220+
int rows_inserted = sqlite3_column_int(stmt, 0);
221+
printf(" * Inserted %d rows into team_activity\n", rows_inserted);
222222
sqlite3_finalize(stmt);
223223

224224
// Get activity count

0 commit comments

Comments
 (0)