<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ollama-web.git/.gitignore, branch v0.5.4</title>
<subtitle>A lightweight personal Ollama Web UI with web search, PDF attachments, and MCP tools.
</subtitle>
<id>https://git.takashi-2521.com/ollama-web.git/atom?h=v0.5.4</id>
<link rel='self' href='https://git.takashi-2521.com/ollama-web.git/atom?h=v0.5.4'/>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/ollama-web.git/'/>
<updated>2026-08-26T10:25:08+00:00</updated>
<entry>
<title>build: uv.lockを追加して依存関係を固定</title>
<updated>2026-08-26T10:25:08+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-08-26T10:25:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/ollama-web.git/commit/?id=43856e7a2fea93d4986b13743f0aa558652a2cd8'/>
<id>urn:sha1:43856e7a2fea93d4986b13743f0aa558652a2cd8</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fix(tools): search_and_fetch のページングトークン破損バグを修正</title>
<updated>2026-08-02T07:18:29+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-08-02T07:18:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/ollama-web.git/commit/?id=af1da765acafec4d7468a79d462427f4245b44db'/>
<id>urn:sha1:af1da765acafec4d7468a79d462427f4245b44db</id>
<content type='text'>
## 背景

search_and_fetch の next_token / continue_from によるページング継続が
PDF 形式で間欠的に失敗するバグが報告された。発生エラー:
  1. payload is not valid JSON: Expecting ':' delimiter
  2. 'utf-8' codec can't decode byte 0xda in position 278

1ページ目の取得自体は成功し、next_token 返却まで正常だが、
next_token を continue_from に渡した2ページ目でエラーが発生。
txt/md/csv/json では安定動作し、PDF で間欠的・再現性なし。

## 根本原因

コード精査の結果、報告の「非UTF-8バイト混入」仮説に対し、より有力な
主因として「トークン巨大化による末尾欠損」を特定:

- _render_file_page() は matched 配列（title/href/body 全部入り）を
  トークンに埋め込んでいたが、レンダリングで使うのは title と href
  のみ。body（DuckDuckGo のスニペット、PDF 論文要約で数KB）は未使用
- 候補複数件でトークンが数KB〜十数KBに膨張
- LLM が continue_from にコピーする際、コンテキスト長や
  _trim_tool_result の切り詰めでトークン末尾が欠損
- base64 デコード結果が不正になり JSONDecodeError（JSON途中切断）
  と UnicodeDecodeError（マルチバイト境界切断）の両エラーが発生
- PDF で間欠的・再現性なしは、検索結果セットごとにスニペット長が
  変動しトークンサイズが破損閾値を前後するためと説明がつく

補助要因: make_token() の ensure_ascii=False が、末尾欠損時に
マルチバイト文字境界で切れる確率を上げていた。

## 修正内容（案A: ユーザー承認済み）

1. pagination.py の make_token() を ensure_ascii=True 化
   - トークンを純ASCII化し、末尾欠損でも UnicodeDecodeError を防止
   - 非ASCII文字は \uXXXX エスケープ（6バイト固定）で安定化

2. fetch.py に _slim_matched() ヘルパーを追加
   - matched から body を除外し title+href のみ埋め込み
   - 3箇所の make_token 呼び出し（fetch失敗時・ファイル内継続時・
     次ファイル移行時）を matched=_slim_matched(matched) に変更
   - トークンサイズを数KB〜十数KB → 数百バイトに削減

3. トークン形式バージョン v は 1維持（構造不変・後方互換）
   - 旧トークン（body入り・ensure_ascii=False）も parse_token で
     正常デコード可能
   - 再検索回避機能も維持

## テスト

tests/test_tools.py に新規テスト5件を追加:
- test_make_token_ensure_ascii_true
- test_search_and_fetch_token_excludes_body
- test_search_and_fetch_token_size_reduced
- test_search_and_fetch_continue_with_slim_token
- test_search_and_fetch_pagination_with_nonascii_title

## 検証結果

- pytest: 113 passed (新規5件含む、既存回帰なし)
- ruff check src/ tests/: All checks passed
- mypy src/: Success: no issues found in 30 source files

## ドキュメント

docs/tools-schema.md に実装ベースの差分を反映:
- make_token() の説明に ensure_ascii=True 化の旨を追記
- search_and_fetch 処理フローの注記に _slim_matched() による
  body 除外とトークンサイズ削減の旨を追記
- トークンペイロード構造の matched 例から body を削除
</content>
</entry>
<entry>
<title>MCP機能追加</title>
<updated>2026-06-26T14:54:17+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-06-26T14:54:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/ollama-web.git/commit/?id=3a9e8e18df4c596360da54000f65e1bebc6039c2'/>
<id>urn:sha1:3a9e8e18df4c596360da54000f65e1bebc6039c2</id>
<content type='text'>
</content>
</entry>
<entry>
<title>ドキュメント最新化</title>
<updated>2026-06-24T15:12:56+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-06-24T15:12:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/ollama-web.git/commit/?id=bf7075d9230ac5fc7f40c28e41aa31f0db93d87f'/>
<id>urn:sha1:bf7075d9230ac5fc7f40c28e41aa31f0db93d87f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Web検索などのツール呼び出しによる応答不能を回避</title>
<updated>2026-06-24T09:11:10+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-06-24T09:11:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/ollama-web.git/commit/?id=f7e2894856c10d8a1e2d429a7858d9f143c42404'/>
<id>urn:sha1:f7e2894856c10d8a1e2d429a7858d9f143c42404</id>
<content type='text'>
</content>
</entry>
<entry>
<title>機能追加(セッション、左ペインでのセッション管理、ファイル取得ツール、pdfテキスト化ツール)</title>
<updated>2026-06-23T15:19:26+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-06-23T15:19:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/ollama-web.git/commit/?id=16a8bfebde12e2e3fa50b2a1384091158fdabe91'/>
<id>urn:sha1:16a8bfebde12e2e3fa50b2a1384091158fdabe91</id>
<content type='text'>
</content>
</entry>
<entry>
<title>ストリーミング出力対応</title>
<updated>2026-06-23T10:24:55+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-06-23T10:24:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/ollama-web.git/commit/?id=5d9fc9c9c976cb6fc7d0b8060abcd2860ebf8456'/>
<id>urn:sha1:5d9fc9c9c976cb6fc7d0b8060abcd2860ebf8456</id>
<content type='text'>
ツール呼び出し、thinkingが応答欄の枠外にでる不具合修正
</content>
</entry>
<entry>
<title>First Commit.</title>
<updated>2026-06-22T16:26:51+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-06-22T16:26:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/ollama-web.git/commit/?id=de0513e7cb0593b1aa141e367ff4da7156d6110f'/>
<id>urn:sha1:de0513e7cb0593b1aa141e367ff4da7156d6110f</id>
<content type='text'>
</content>
</entry>
</feed>
