Stabilize product data export flow

This commit is contained in:
wuyang6
2026-05-11 11:46:09 +08:00
parent 1752c81913
commit 0e2a00990f
19 changed files with 659 additions and 31 deletions
+33 -5
View File
@@ -429,7 +429,8 @@ def build_data_agent_tools(handlers: Mapping[str, ToolHandler]) -> list[AgentToo
description=(
'Parse dataset draft text written with 用户/小爱/target blocks and build canonical '
'data-agent records with generated record IDs, timestamps, source metadata, context, and labels. '
'Generated data requires a confirmed_plan_id from data_agent_confirm_generation_plan.'
'Generated data requires a confirmed_plan_id from data_agent_confirm_generation_plan. '
'Use draft_path instead of draft_text when the draft is large or contains many quoted targets.'
),
parameters={
'type': 'object',
@@ -438,6 +439,10 @@ def build_data_agent_tools(handlers: Mapping[str, ToolHandler]) -> list[AgentToo
'type': 'string',
'description': 'Dataset draft text in dataset draft text v1 format.',
},
'draft_path': {
'type': 'string',
'description': 'Path to a UTF-8 dataset draft text file. Prefer this for large drafts.',
},
'batch_id': {
'type': 'string',
'description': 'Batch identifier used in generated record_id values.',
@@ -464,7 +469,10 @@ def build_data_agent_tools(handlers: Mapping[str, ToolHandler]) -> list[AgentToo
'description': 'Required for generated data; returned by data_agent_confirm_generation_plan.',
},
},
'required': ['draft_text'],
'anyOf': [
{'required': ['draft_text']},
{'required': ['draft_path']},
],
},
handler=resolve_handler(handlers, 'data_agent_normalize_dataset_draft', 'data-agent'),
),
@@ -484,8 +492,15 @@ def build_data_agent_tools(handlers: Mapping[str, ToolHandler]) -> list[AgentToo
],
'description': 'Canonical records as an array, or a JSON string containing the array.',
},
'records_path': {
'type': 'string',
'description': 'Path to records JSON/JSONL. Prefer this when records are large.',
},
},
'required': ['records'],
'anyOf': [
{'required': ['records']},
{'required': ['records_path']},
],
},
handler=resolve_handler(handlers, 'data_agent_validate_dataset_records', 'data-agent'),
),
@@ -493,7 +508,8 @@ def build_data_agent_tools(handlers: Mapping[str, ToolHandler]) -> list[AgentToo
name='data_agent_export_dataset_records',
description=(
'Validate canonical data-agent records and write them to a workspace file. '
'Defaults to compact JSONL, one canonical record per line, so the model does not hand-write JSON output.'
'Defaults to compact JSONL, one canonical record per line, and also writes records.csv '
'in the same output directory for human sharing.'
),
parameters={
'type': 'object',
@@ -505,6 +521,10 @@ def build_data_agent_tools(handlers: Mapping[str, ToolHandler]) -> list[AgentToo
],
'description': 'Canonical records as an array, or a JSON string containing the array.',
},
'records_path': {
'type': 'string',
'description': 'Path to records JSON/JSONL. Prefer this when records are large.',
},
'output_path': {
'type': 'string',
'description': (
@@ -526,8 +546,16 @@ def build_data_agent_tools(handlers: Mapping[str, ToolHandler]) -> list[AgentToo
'type': 'boolean',
'description': 'When false, refuse to overwrite an existing file.',
},
'export_table': {
'type': 'boolean',
'description': 'Defaults to true. Also write records.csv with the shared spreadsheet columns.',
},
},
'required': ['records', 'output_path'],
'required': ['output_path'],
'anyOf': [
{'required': ['records']},
{'required': ['records_path']},
],
},
handler=resolve_handler(handlers, 'data_agent_export_dataset_records', 'data-agent'),
),