Skip to content

feat(tools): plan service tools one step at a time - #43

Merged
Twcat0503 merged 2 commits into
mainfrom
feat/townpass-step-planner
Nov 7, 2026
Merged

Twcat0503 merged 2 commits into
mainfrom
feat/townpass-step-planner

Conversation

@him6794

@him6794 him6794 commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

改了什麼、為什麼

工具生成從「模型一次輸出整份計畫」改為「每次只回答一個小問題」,並修正兩個已知問題:OpenAPI 同一操作重複成兩個工具,以及 type="time" 的 14:30 被拒絕。本機解析模型的中文能力與上下文都有限,因此拆成小步驟,每一步只提供該步需要的觀測資料。

  • 頁面:每個輸入控制項各一次呼叫(回答參數名稱);送出按鈕、結果區、工具名稱與描述各一次。
  • API:每個操作各一次呼叫,決定是否提供並命名。
  • 步驟依序執行,任一步失敗即停止,不重試。整體計畫仍經 planService 驗證後才組出工具。
  • 模型先以英文寫一句 thought。thought 與描述的文法限制寫在 pattern 內:不含雙引號與反斜線,且最多 200 字元。

Commits(疊加在 #39 之上):

  1. fix(tools): offer each OpenAPI operation at most once(既有)
  2. feat(tools): plan service tools one step at a time

第 2 個 commit 依賴第 1 個的 apiCatalog。兩者都是工具生成的改進,因此放在同一個 PR;若維護者要求拆開,可改為兩個疊加 PR。

Base 為 feat/townpass-service-registry(#39)。#39 合併後,此 PR 應改回 main。

如何驗證

  • pnpm typecheck:通過
  • pnpm test:10 個測試檔,112 項通過,2 項略過(catalog-routes.test.ts 的路由測試需要此分支沒有的 Vue router 檔案)
  • 真實模型(LFM3 1.7B Q4_0,推理關閉,Vulkan 於 GPU):四服務嚴格驗收(日期查詢、圖書查詢、多欄位課程查詢、OpenAPI POST)連續三次通過。驗收腳本屬於前端 PR,不在本 PR 內。
  • 五服務穩定性:25/25(每服務 5 次),每服務的五次結構相同。這五個服務在調整提示時已反覆使用,不是對未見過服務的泛化證據。
  • GPU(Windows 計數器,每秒取樣,穩定性測試期間):解析模型行程的 3D 引擎峰值約 42%;Compute 引擎為 0%;專用記憶體約 1.3 GB。

已知限制

  • 未見過服務的表現尚未驗證;參數名稱的語意有時較弱(例如 keyword_keyword)。
  • 頁面的模型呼叫次數為「輸入控制項數 + 3」,延遲隨頁面大小線性增加。
  • 行為變更:部分控制項映射會被拒絕(每個觀測到的輸入控制項都必須有參數名稱);service-plan.test.ts 的兩項舊期望依此改寫。
  • 手機與原生測試未在本次修改後重跑。

Checklist

  • 一個 PR 只做一件事,沒有夾帶無關變更(見上方說明,待維護者確認)
  • 已執行所屬棧的自檢指令並將結果貼於上方(tools:pnpm typecheck/pnpm test)
  • Flutter 變更已於 Android 裝置/模擬器驗證(無 Flutter 變更,不適用)
  • 設計自檢通過(無 UI 變更,不適用)
  • diff 中沒有 API key、token 等機密,也沒有個人環境檔或內部文件
  • 新增的相依套件為開源且與 AGPL-3.0 相容(本次無新增相依套件)

相關 issue(若有)

無

Copilot AI balanced review requested due to automatic review settings November 7, 2026 21:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Model the OpenAPI operations as an object keyed by operation, so a
single operation can produce at most one tool. Before, the model could
return the same operation several times under different names.

- Keys are the documented METHOD URL pairs; unknown keys are rejected.
- An empty selection is rejected instead of saving no tools.
- Two different operations with the same tool name are rejected.
- Update the contract description and the verification notes.
Replace the single model call that produced a whole tool plan with a
sequence of short calls. A page gets one call per input control (for its
parameter name), one for the submit control, one for the result element,
and one for the tool name and description. Each OpenAPI operation gets one
call that decides whether to expose it and names it. Steps run in order
and stop at the first failure; there are no retries.

Each answer starts with a one-sentence English "thought". The thought and
the description are bounded inside their patterns: the thought is printable
ASCII without double quotes or backslashes, the description has no double
quotes or backslashes, and both are at most 200 characters. An unbounded
string let one call generate more than 10,000 tokens, and a double quote
could end the JSON string early.

Also:
- Result candidates exclude input and submit controls.
- Every observed input control must receive a parameter name.
- type="time" uses an HH:MM pattern; format "time" rejected "14:30".
- planService still validates the combined plan before any tool is stored.
@Twcat0503
Twcat0503 changed the base branch from feat/townpass-service-registry to main November 7, 2026 23:30
@Twcat0503
Twcat0503 force-pushed the feat/townpass-step-planner branch from 1547315 to 47a8dd0 Compare November 7, 2026 23:30
@Twcat0503
Twcat0503 merged commit 40827cf into main Nov 7, 2026
7 checks passed
@Twcat0503
Twcat0503 deleted the feat/townpass-step-planner branch November 7, 2026 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants