Skip to content

Commit 610d9c3

Browse files
get_dataset_schema tool to return compact TSV response
1 parent e0151dd commit 610d9c3

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎src/handlers/http/logstream.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ fn schema_response(schema: &Schema, format: SchemaFormat) -> HttpResponse {
205205
}
206206
}
207207

208-
fn compact_schema(schema: &Schema) -> String {
208+
/// Render the token-efficient schema representation used by the compact HTTP
209+
/// response and by agent-facing schema tools.
210+
pub fn compact_schema(schema: &Schema) -> String {
209211
let mut output = String::from("name\ttype\n");
210212
for field in schema.fields() {
211213
append_escaped_compact_field(&mut output, field.name());

‎src/tool_catalog.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ pub fn oss_read_tool_specs() -> Vec<ToolSpec> {
356356
ToolSpec::new(
357357
"get_dataset_schema",
358358
"Get dataset schema",
359-
"Get columns and data types for a dataset.",
359+
"Get all dataset columns and data types as compact tab-separated text with a name/type header.",
360360
dataset_schema(),
361361
),
362362
ToolSpec::new(

‎src/tool_executor.rs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,10 @@ async fn execute_dataset_metadata_tool(
272272
match name {
273273
"get_dataset_schema" => {
274274
authorize(context.session_key, Action::GetSchema, Some(dataset), None)?;
275-
serde_json::to_value(
276-
logstream::get_schema_internal(dataset, context.tenant_id)
277-
.await
278-
.map_err(|error| error.to_string())?,
279-
)
280-
.map_err(|error| error.to_string())
275+
let schema = logstream::get_schema_internal(dataset, context.tenant_id)
276+
.await
277+
.map_err(|error| error.to_string())?;
278+
Ok(Value::String(logstream::compact_schema(&schema)))
281279
}
282280
"get_dataset_info" => {
283281
authorize(

0 commit comments

Comments
 (0)