20 Feb, 2026

3 commits

  • - Search image_url: parse results[].image_url, add _normalize_image_url() to
      convert protocol-less URLs (////host/path) to https://host/path; fix double
      slash (use https:// + url.lstrip("/") so normalized URL has single //).
    - Logging: log full LLM request/response (LLM_REQUEST, LLM_RESPONSE), full
      tool call results (TOOL_CALL_RESULT); for search tool log SEARCH_RESULT
      summary and per-item SEARCH_RESULT_ITEM (image_url_raw) and
      SEARCH_RESULT_PRODUCT (image_url_normalized).
    - Streamlit: replace deprecated use_container_width=True with width="stretch"
      for st.image and st.button.
    
    Co-authored-by: Cursor <cursoragent@cursor.com>
    tangwang
     
  • ## 搜索结果管理与人机回复引用
    - 新增 app/search_registry.py:SearchResultRegistry + SearchResult/ProductItem 数据结构,按 session 存储每次搜索的 query、质量评估与商品列表。
    - 搜索工具改为工厂 make_search_products_tool(session_id, registry):每次搜索后由 LLM 对 top20 打标(完美匹配/部分匹配/不相关),产出整体 verdict(优质/一般/较差),仅将「完美+部分」写入 registry 并返回摘要 + [SEARCH_REF:ref_id];不再向 Agent 返回完整商品列表。
    - 废除 extract_products_from_response:最终回复中通过内联 [SEARCH_REF:xxx] 引用「搜索结果块」,UI 用 SEARCH_REF_PATTERN 解析后从 registry 取对应 SearchResult 渲染 query 标题 + 商品卡片,避免 LLM 复述商品列表,节省 token 并减少错误。
    
    ## 系统提示与行为约束
    - 系统提示词通用化(不绑定时尚品类),明确四步:理解意图 → 规划 2~4 个 query → 执行搜索并评估 → 撰写回复。
    - 要求同一条回复中并行发起 2~4 次 search_products(不同 query),利用 LangGraph ToolNode 的并行执行缩短等待;禁止串行「搜一个看一个再搜下一个」。
    - 轮次上限:最多两轮搜索(两轮 = 两次「Agent 发 tool_calls → Tools 执行 → 返回」);若已有优质/一般结果则直接写回复,仅当全部较差时允许第二轮(最多再 1~2 个 query)。图逻辑增加 n_tool_rounds 状态与 agent_final 节点,两轮后强制进入「仅回复、不调工具」的 agent_final,避免无限重搜。
    
    ## 前端与工具导出
    - app.py:render_message_with_refs(content, session_id) 按 [SEARCH_REF:xxx] 切分并渲染;render_search_result_block 展示 query + 质量 + 商品卡片;display_product_card_from_item 支持 image_url/本地图/占位;Clear Chat 时 clear_session(registry)。
    - app/tools/__init__.py:改为导出 make_search_products_tool、web_search,不再导出已移除的 search_products 顶层名。
    
    Co-authored-by: Cursor <cursoragent@cursor.com>
    tangwang
     
  • tangwang
     

18 Feb, 2026

1 commit


12 Feb, 2026

4 commits