mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-11-05 07:39:47 +00:00
* fix(frontmatter-read): put the frontmatter in the answer, not just a key count `frontmatter_read` answered `Read frontmatter from <path> (N key(s))` and left the frontmatter itself in `metadata["frontmatter"]`. MCP returns only `response.answer`, so the LLM that asked for a file's frontmatter learned how many keys exist and nothing else — the same shape of gap #379 describes for `list`, where the caller cannot act on the result. Render each key on its own line in the answer. Values are flattened to one line each so a multi-line description cannot break the line-per-key layout: lists join with commas and nested mappings render as compact JSON. An empty frontmatter says `(no keys)` rather than trailing off after the colon. The answer also names the probed path instead of the raw input, so a suffix-less request reports the `.md` file that was actually read and the caller can follow up with `read` without consulting metadata. Structured `metadata["frontmatter"]` is unchanged, so programmatic consumers see no difference. Towards #379. * docs(config): match the frontmatter_read description to the new answer The job description still advertised "Read a file's frontmatter as a dict", but the answer is now rendered `key: value` lines — the dict only survives in metadata. An LLM choosing between `frontmatter_read` and a whole-file `read` would expect a dict it can index into and get prose instead. This is the wording-alignment point raised on #397, applied here before review rather than after. * fix(frontmatter-read): never fail a valid YAML read on rendering Review on #564 found two rendering regressions plus boundary losses: - json.dumps(..., sort_keys=True) raised on datetime.date values (YAML timestamps) and on mixed-type mapping keys, turning a parseable frontmatter into a failed job with empty metadata - the base revision read those files fine. - Comma-joining lists lost item boundaries (["a, b", "c"] read back as one ambiguous string), [] was indistinguishable from an empty string, and the whitespace collapse also mangled spaces inside serialized values. _render_value is now a single tolerant renderer: bare strings keep their text but have line breaks escaped; everything else goes through json.dumps(ensure_ascii=False, default=str) (no key sort) so collections stay structured and YAML-only types serialize; anything JSON still cannot represent falls back to repr. Keys are rendered through the same path so a multiline key cannot break the one-key-per-line layout either. The structured metadata contract is untouched. Also aligns the benchmark.yaml job description with the textual answer (default.yaml already says 'one key: value per line') and the module docstring now distinguishes the textual answer from the structured payload in metadata. Regression coverage: nested dates, mixed mapping keys, empty lists, comma-containing items, significant whitespace, and a literal block scalar with a real newline. * fix(frontmatter-read): use json.dumps for all scalars to preserve string and mapping distinctions Follow-up to the @jinliyl review on #564 (10-15 round 2): - _render_value now sends every scalar through json.dumps rather than the str-only branch. The str-only branch collapsed a literal '\n' two-character sequence and an actual newline into the same rendered form ('\n') and lost the distinction between the string 'null' and YAML null. The JSON form preserves both. - Mixed mapping key types (int 1 vs string '1') now round-trip with their JSON-form distinction in the answer, matching the metadata. Callers that re-parse the answer body as JSON still discard one value (this is a YAML-side limitation, not a renderer one); pinned by a regression test. - Updated the three existing answer assertions to carry the new quoted scalar form, and added two regression tests: test_read_answer_distinguishes_newline_from_literal_backslash_n and test_read_answer_mixed_mapping_key_types_render_via_json. Note: the str-only branch's '\n' escape was the only reason the description: |- literal-block test in test_read_answer_tolerates_rich_yaml_types rendered as 'line one\\nline two'. With the change, the same description renders as '"line one\nline two"' (real newline, JSON- escaped), which is exactly the fix the review asked for. * fix(frontmatter-read): split key/value rendering so keys are not JSON-quoted The round-2 change sent every scalar (including string keys) through json.dumps, which added quotes around string keys. The rendered answer came out as '- "name": "Cobalt"' instead of '- name: "Cobalt"' on the round-2 head; the 5 new and updated tests in test_frontmatter_steps all failed for that reason on Unit Tests - py3.11 through py3.14. Split the renderer: - _render_key: pass-through str(key) so the answer reads as '- key:'. - _render_value: still json.dumps (with default=str and ensure_ascii=False) for the structural pinning the round-2 review asked for (literal '\n' vs actual newline, the string 'null' vs YAML null, mixed mapping key types). Caller formats the line as '- {key}: {value}'. Updated the three existing answer assertions to match the key-unchanged, value-quoted shape (e.g. '- name: "Cobalt"'). The two new tests added in the round-2 commit (newline, mixed keys) were already pinned on the right shape; the round-1 key-quote was the only bug. * fix(frontmatter-read): JSON-encode keys too so every answer entry stays on one line A multiline YAML key broke the one-key-per-line layout because keys were interpolated raw. Route keys through the same json.dumps renderer as values, update the expected answers to the quoted-key form, correct the renderer docstring and mixed-key test comments (JSON collapses int 1 and string "1" keys alike — the metadata keeps the distinction), and pin the rich-type answer to the quoted "created": "2026-10-12" rendering. * test(frontmatter-read): cover multiline keys, reseed YAML blocks as literal strings Add the multiline-key regression the review asked for, restate the mixed-mapping-key case as a documented presentation limitation (JSON stringifies both keys, so a re-parser keeps only the last value), and write the YAML seeds as triple-quoted literals so black stops joining the implicit concatenations and pylint's implicit-str-concat goes quiet. * refactor(frontmatter-read): simplify answer rendering --------- Co-authored-by: jinli.yl <jinli.yl@alibaba-inc.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| auto_resource_test_plugin.py | ||
| auto_resource_test_support.py | ||
| file_store_test_support.py | ||
| test_agent_state_io.py | ||
| test_app_config_step.py | ||
| test_application_config.py | ||
| test_as_embedding_lazy.py | ||
| test_as_llm_lazy.py | ||
| test_async_utils.py | ||
| test_atomic_file_write.py | ||
| test_auto_dream.py | ||
| test_auto_image_steps.py | ||
| test_auto_memory_cc.py | ||
| test_auto_memory_direct_images.py | ||
| test_auto_memory_idempotency.py | ||
| test_auto_memory_session_messages.py | ||
| test_auto_resource_agent_inputs.py | ||
| test_auto_resource_batch_lookup.py | ||
| test_auto_resource_review_regressions.py | ||
| test_auto_tag.py | ||
| test_background_steps.py | ||
| test_base_agent_wrapper.py | ||
| test_base_component.py | ||
| test_benchmark_docker.py | ||
| test_benchmark_docker_queries.py | ||
| test_benchmark_docker_upload.py | ||
| test_benchmark_docker_workspace.py | ||
| test_bm25_live_length.py | ||
| test_cc_agent_wrapper.py | ||
| test_codex_agent_wrapper.py | ||
| test_codex_plugin_mcp.py | ||
| test_codex_plugin_runtime.py | ||
| test_coding_agent_plugins.py | ||
| test_common_steps.py | ||
| test_compact_context.py | ||
| test_compaction_experiment.py | ||
| test_compaction_study.py | ||
| test_component_registry.py | ||
| test_compressor_step.py | ||
| test_config_parser.py | ||
| test_cookbook_config.py | ||
| test_crud_steps.py | ||
| test_daily_list_range.py | ||
| test_daily_note_links.py | ||
| test_daily_steps.py | ||
| test_decision_config.py | ||
| test_decision_demo.py | ||
| test_decision_model.py | ||
| test_default_file_chunker.py | ||
| test_docker_runtime.py | ||
| test_dream_checkpoint_versions.py | ||
| test_embedded_consumer_compat.py | ||
| test_evaluation_interface.py | ||
| test_evolve_utils.py | ||
| test_faiss_index_maintenance.py | ||
| test_file_catalog.py | ||
| test_file_graph.py | ||
| test_file_sandbox_backend.py | ||
| test_file_store_consistency.py | ||
| test_frontmatter_steps.py | ||
| test_graph_snapshot_step.py | ||
| test_hermes_agent_integration.py | ||
| test_http_client.py | ||
| test_http_web_workspace.py | ||
| test_injected_job_kwargs.py | ||
| test_job.py | ||
| test_json_file_chunker.py | ||
| test_jsonl_file_chunker.py | ||
| test_keyword_index.py | ||
| test_line_anchor.py | ||
| test_link_expansion.py | ||
| test_local_backend.py | ||
| test_local_embedding_store.py | ||
| test_logging_config.py | ||
| test_logo_utils.py | ||
| test_markdown_file_chunker.py | ||
| test_mcp_client.py | ||
| test_memlens_benchmark.py | ||
| test_memlens_judge.py | ||
| test_memlens_runner_failures.py | ||
| test_mobilemem_audit.py | ||
| test_mobilemem_benchmark.py | ||
| test_mobilemem_judge.py | ||
| test_outbound_proxy.py | ||
| test_package_versions.py | ||
| test_packaging.py | ||
| test_path_bubble_backend.py | ||
| test_path_permission.py | ||
| test_plugin.py | ||
| test_plugin_cli.py | ||
| test_prepared_search_filter.py | ||
| test_proactive_refresh.py | ||
| test_process_output_limits.py | ||
| test_prompt_handler.py | ||
| test_qwen_token_tools.py | ||
| test_read_image_steps.py | ||
| test_read_newlines.py | ||
| test_read_with_neighbors.py | ||
| test_reindex.py | ||
| test_reme_cli.py | ||
| test_runtime_context.py | ||
| test_sandbox_startup_cancellation.py | ||
| test_search_empty_response.py | ||
| test_search_score_threshold.py | ||
| test_search_step.py | ||
| test_service.py | ||
| test_service_utils.py | ||
| test_session_image_assets.py | ||
| test_shell_step.py | ||
| test_source_format_merge.py | ||
| test_status_step.py | ||
| test_sync_qwenpaw_agentscope.py | ||
| test_tag_index.py | ||
| test_threaded_watch.py | ||
| test_token_usage.py | ||
| test_tokenizer.py | ||
| test_utils.py | ||
| test_wikilink_utils.py | ||
| test_workspace_web_steps.py | ||
| test_write_metadata_lock.py | ||
| test_zvec_file_store.py | ||