@tiens.nguyen/gonext-local-worker 1.0.253 → 1.0.254

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3117,11 +3117,17 @@ def run_agent_chat(cfg):
3117
3117
  [_active_ws] if _active_ws else _WS_ROOTS
3118
3118
  ) if _WS_AVAILABLE else []
3119
3119
  _ws_overview = _workspace_overview(_overview_roots) if _overview_roots else ""
3120
- _ws_tool_block = (
3120
+ # VARIABLE workspace context (task #86): the active-folder line, workspace list and
3121
+ # the on-disk folder overview change between turns (the agent creates/edits files),
3122
+ # so they must NOT sit inside the static tool_hint — they'd bust the prefix cache
3123
+ # mid-reference every turn. They join the variable tail of task_with_hint instead.
3124
+ _ws_context_block = (
3121
3125
  _ws_current_line
3122
3126
  + f" Other registered workspaces (use only if the user names them): {_ws_names}\n"
3123
3127
  f" Current folder contents:\n"
3124
3128
  + "\n".join(f" {line}" for line in _ws_overview.splitlines()) + "\n"
3129
+ ) if _WS_AVAILABLE else ""
3130
+ _ws_tool_block = (
3125
3131
  " - list_dir(path) / read_text_file(path) — browse and read files.\n"
3126
3132
  " - grep_repo(pattern, path='', glob='') — search code, returns file:line hits. "
3127
3133
  "Use this to find the EXACT lines to change.\n"
@@ -3225,19 +3231,18 @@ def run_agent_chat(cfg):
3225
3231
  f"(Permission denied publickey,password), STOP and tell the user to run "
3226
3232
  f"'ssh-copy-id {_du}@{_dh}' once, then retry. ***\n"
3227
3233
  )
3234
+ # STATIC ONLY (task #86): everything in tool_hint must be byte-identical between
3235
+ # turns so the model server's prefix KV-cache covers it (see task_with_hint below).
3236
+ # Variable text — the deploy target and the current date/time — lives in the
3237
+ # variable tail next to the task instead.
3228
3238
  tool_hint = (
3229
- # Deploy target FIRST (when a server is picked) a small model buries context deep
3230
- # in a 20k-char hint, so the chosen server must lead, not trail (task #69 retest fix).
3231
- _deploy_block
3232
- + f"Solve the TASK step by step (up to {max_steps} steps). At EACH step write a "
3239
+ f"Solve the TASK step by step (up to {max_steps} steps). At EACH step write a "
3233
3240
  "brief Thought, then ONE code block that calls a SINGLE tool. You will SEE that "
3234
3241
  "tool's result (Observation) before the next step — use it to decide what to do "
3235
3242
  "next (e.g. web_search to find a URL, THEN fetch_url to read it). When you have "
3236
3243
  "enough to answer, call final_answer(<your answer>) in a code block. Prefer "
3237
3244
  "FEWER steps, and never repeat a tool call that already succeeded.\n\n"
3238
3245
  "{{TOOL_LIST}}\n" # filled in below, once from the REAL registered tool objects
3239
- f"(Current date/time: {now_str} — pass a timezone to get_current_datetime() only "
3240
- "if the task needs a DIFFERENT one.)\n"
3241
3246
  + _rag_tool_block + _ws_tool_block + _auto_test_block +
3242
3247
  "\n"
3243
3248
  "http_request RETURN FORMAT: 'HTTP 200\\n{body}' — first line is 'HTTP <code>', body follows.\n"
@@ -3322,14 +3327,30 @@ def run_agent_chat(cfg):
3322
3327
  f"Previous task: {_ck.get('task', '')}\n" + "\n".join(_kept)
3323
3328
  )
3324
3329
 
3325
- # Lead with the TASK so the weak model anchors on what's actually being asked —
3326
- # not on the tool reference below. (Previously the hint led with the date, and the
3327
- # 3B model treated every message as a date question.)
3330
+ # ORDER (task #86 prefix-cache fix): STATIC first, VARIABLE last.
3331
+ # The ~16k-char tool reference is byte-identical between turns; leading with it
3332
+ # (right after the equally static system prompt) lets the model server's prefix
3333
+ # KV-cache cover ~7k tokens across turns. Previously the variable task text came
3334
+ # FIRST, so every new turn forced a cold re-eval of the whole reference (~2 min to
3335
+ # first token on step 1 of each turn; steps 2+ were 10-30s because within a turn
3336
+ # the prompt only grows at the end).
3337
+ # The TASK now comes LAST, under a loud header: recency is the position a model
3338
+ # attends to most, so anchoring is preserved (the historical "hint led with the
3339
+ # date → 3B model answered everything as a date question" regression was about a
3340
+ # misleading LEAD, not about where the task sits). The two VARIABLE blocks — the
3341
+ # current date/time and the deploy target — live here in the tail, next to the
3342
+ # task: the deploy target must stay near the task, not buried mid-hint (#69), and
3343
+ # the timestamp changes every minute, which would bust the cache mid-reference.
3328
3344
  task_with_hint = (
3329
- "TASK (answer THIS, choose the tool that fits it):\n"
3330
- f"{task_text}\n\n"
3331
- "----- TOOL REFERENCE -----\n"
3332
- + tool_hint
3345
+ "----- TOOL REFERENCE (how to work your actual TASK follows below) -----\n"
3346
+ + tool_hint +
3347
+ "\n----- YOUR TASK -----\n"
3348
+ f"(Current date/time: {now_str} — pass a timezone to get_current_datetime() only "
3349
+ "if the task needs a DIFFERENT one.)\n"
3350
+ + _deploy_block
3351
+ + _ws_context_block +
3352
+ "\nTASK (answer THIS, choose the tool that fits it):\n"
3353
+ f"{task_text}\n"
3333
3354
  )
3334
3355
 
3335
3356
  # Track URLs that have already failed so we don't retry dead endpoints across steps.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.253",
3
+ "version": "1.0.254",
4
4
  "description": "Polls GoNext cloud API for async local LLM jobs and runs them against Ollama/OpenAI-compatible servers on this Mac",
5
5
  "type": "module",
6
6
  "license": "MIT",