Skip to main content
Glama

Deadwax

CI

個人のリスニング履歴に対するエージェント型ミュージックライブラリアンです。何を聴いたかについての自然言語の質問に答え、厳格な制約に基づいてプレイリストを構築します。決定的なバリデーター、修復ループ、そして合格/不合格ではなく合格率を報告する評価スイートを備えています。

ツール使用、検索、トレーシング、評価、MCPといった本番レベルのLLMエンジニアリング実践を示すポートフォリオ作品として構築されました。

面白い部分

ほとんどのLLMデモは、2回実行するまでは機能します。Deadwaxは、2回目の実行で何が起こるかを中心に構築されています。

システムは一線で分割されています。モデルは決して計算しません。 モデルは言語を解釈し、ツールを選択し、散文を構成します。すべての算術演算、閾値チェック、制約の判定は、LLMの存在を知らない素のPythonで行われます。プレイリストが制約に違反した場合、バリデーターはFalseを返すのではなく、違反コード、問題のトラックID、具体的な修正方法を返します。これこそが、自動修復ループが機能する唯一の理由です。

実現可能性は生成の前にチェックされます。ブリーフを満たせない場合、システムはその旨を明言します。パディング、代替、黙っての劣化は決して行いません。status="infeasible"は、独自の評価ケースを持つ正しい結果です。

Related MCP server: YouTube Music MCP Server

アーキテクチャのルール

スタイル上の好みではありません。これらに違反すると、プロジェクトの目的が損なわれます。

  1. モデルは決して計算しない。

  2. ツールの説明は動作の制御です。プロンプトであり、ドキュメントではありません。変更は動作の変更であり、マージ前に再評価されます。

  3. 違反は機械が実行可能な形で示されます。コード、問題のID、修正方法。裸のブール値や散文だけでは不十分です。

  4. 実現可能性は生成前にチェックされます。

  5. 失敗は有効な結果です。

  6. ハード制約は測定され、強制されます。ソフト制約は推論され、スコア化され、それについてのメッセージは必ず開示しなければならないprovenanceフィールドを持ちます。

  7. トレースなしのモデル呼び出しはありません。

決定とそのトレードオフはdocs/adrに記録されています。

スタック

すべて無料枠で動作します。これは好みではなく、厳格な制約です。

層

選択肢

言語

Python 3.13

ツールチェーン

uv(依存関係とPython自体の管理)、ruff(lintとフォーマット)、pytest

エージェント

LangChain(ステージ3で導入、それ以前ではない)

モデル

Google Gemini Flash(OpenRouterフォールバック付き)

ストア

sqlite3標準ライブラリモジュールによるSQLite

検索

ビルド時の埋め込み、素のPythonでのコサイン類似度 — ベクトルデータベースなし

トレーシング

Langfuse

相互運用

Model Context Protocolサーバー

フロントエンド

Cloudflare Pages上のAstro — 唯一のJavaScriptコンポーネント

ステージ0から2までは標準ライブラリのみを使用します。フレームワーク、SDK、依存関係はありません。生のHTTP呼び出しは、抽象化が導入される前に手書きで行われます。これにより、フレームワークが実際の動作を誤って表現した場合に、その違いが明確になります。

ビルドの進捗

12のステージ、4つのフェーズ。各ステージにつき1つのブランチと1つのスカッシュマージPRがあり、履歴は実際のビルドの進行を反映しています。

フェーズ

ステージ

ステータス

A · 基盤

0 · 生の呼び出し1回

🔨 進行中

A · 基盤

1 · フィクスチャデータ

⬜

A · 基盤

2 · 決定的コア

⬜

B · エージェント

3 · 最初のツールループ

⬜

B · エージェント

4 · 揺らぎの測定

⬜

B · エージェント

5 · 評価ハーネス

⬜ v0.5

C · 品質向上

6 · 修復ループ

⬜

C · 品質向上

7 · 敵対的ケース

⬜

C · 品質向上

8 · トレーシング

⬜

C · 品質向上

9 · 検索

⬜ v0.9

D · 出荷

10 · 実データ

⬜

D · 出荷

11 · MCPサーバー

⬜

D · 出荷

12 · サイトと解説

⬜ v1.0

実行方法

uvが必要です。uvはPython自体をインストールおよび管理するため、唯一の前提条件です。

winget install --id=astral-sh.uv -e

次に、リポジトリのルートから:

uv sync

これにより仮想環境が作成され、.python-versionから固定されたPythonバージョンがインストールされ、プロジェクトがインストールされます。

Google AI Studioから無料のGemini APIキーを追加します:

copy .env.example .env

GEMINI_API_KEY=の後にキーを貼り付けます。次に、無料枠のカタログは予告なく変更されるため、キーがアクセスできるモデルを確認します:

uv run scripts/raw_call.py --list

そのIDのいずれかを.envにGEMINI_MODELとして設定し、呼び出しを実行します:

uv run scripts/raw_call.py

このスクリプトは、回答を抽出する前に完全なリクエストと完全なレスポンスを出力します。これがスクリプトの要点です。フレームワークがそれらを隠す前に、その形状を知っておく価値があります。

アカウントの実際のレート制限はaistudio.google.com/rate-limitに表示されます。GoogleはAPIドキュメントでモデルごとの無料枠テーブルを公開しなくなりました。

評価

評価スイートはステージ5で導入されます。ケースは手書きであり、決して生成されません。同じツールがコードと採点の両方を書く場合、スコアは意味を持ちません。スコアは繰り返し実行の合格率として報告されます。非決定的システムでの1回の合格は逸話に過ぎないからです。

プロンプト、ツールの説明、またはモデルを変更するコミットには、そのメッセージに変更前後の評価スコアが含まれます。

ライセンス

MIT。 LICENSE を参照してください。

David Koen によって構築されました。

Available Tools

4 tools
check_feasibilityA
Read-only

Check whether a playlist brief is possible at all, before choosing any tracks.

Call this first, before query_library, whenever the user asks for a playlist with constraints. If feasible is false the brief cannot be satisfied by this library: tell the user which constraint fails and stop. Do not build a playlist anyway, do not relax the constraint yourself, and do not try alternative track combinations.

max_achievable_display is the longest playlist the library can produce under these constraints. When explaining a refusal, describe what the user asked for in their own words and quote max_achievable_display for what is possible. Never show the user a millisecond figure and never convert one yourself.

A brief with no constraints at all cannot be checked. If the user has not said how long the playlist should be or what should be in it, ask them before calling this.

NameRequiredDescriptionDefault
released_afterNo
released_beforeNo
required_genresNo
max_track_duration_msNo
max_tracks_per_artistNo
min_total_duration_msNo

TDQS

A4.3/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare a safe read-only, closed-world operation, and the description goes well beyond them: it discloses the 'feasible' boolean and 'max_achievable_display' return semantics, plus a refusal protocol and a presentation rule (never surface or convert millisecond figures). That is real behavioral context an agent could not infer from readOnlyHint alone.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core purpose and the sequencing rule, and most sentences add distinct policy. The refusal paragraph slightly over-enumerates ('do not build a playlist anyway, do not relax the constraint yourself, and do not try alternative track combinations'), which are three phrasings of one instruction.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a six-parameter, no-output-schema tool the usage and refusal policy are complete, but the description omits any explanation of the parameter formats an agent must supply, which is the main remaining risk. It explains two return fields but not the full result shape.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description carries the full burden for six parameters, yet it never explains any of them. It is ambiguous whether released_after/released_before are years or epoch timestamps, and units for max_track_duration_ms and min_total_duration_ms are only obliquely implied by the millisecond warning.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('check whether a playlist brief is possible') and positions it temporally ahead of track selection, which distinguishes it from query_library and validate_playlist. An agent knows immediately that this is a pre-flight gate, not a builder or validator.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit when-to-call ('first, before query_library, whenever the user asks for a playlist with constraints'), explicit when-not ('a brief with no constraints at all cannot be checked — ask them before calling'), and explicit failure behavior ('tell the user which constraint fails and stop', 'do not relax the constraint yourself'). Alternatives and exclusions are both covered.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

enrich_artistA
Read-only

Look up background on one artist in the user's library, from published sources.

Call this for any question about an artist's history, members, origins, influences or career. Pass the artist's name and the user's question. It returns the passages from MusicBrainz and Wikipedia that best match the question.

Answer only from these passages. If they do not contain the answer, tell the user your sources do not cover it, even if you believe you know. Never fill the gap from your own knowledge.

Cite every passage you use by its id in square brackets, such as [can-03], straight after the claim it supports. Never cite an id this tool did not return.

This tool knows nothing about the user's tracks. Use query_library for those.

NameRequiredDescriptionDefault
artistYes
questionYes

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the readOnly/openWorld annotations by disclosing the data sources (MusicBrainz, Wikipedia), the grounding contract (answer only from returned passages, refuse otherwise), and the citation protocol required in the reply. These are response-shaping rules the annotations cannot convey.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose, then usage, then output contract, then sibling routing. Every sentence adds an actionable rule; nothing is redundant with the schema or annotations.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description supplies the return shape ('passages ... that best match the question') along with the id format used in citations. An agent has everything needed to call it and to post-process the result correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must compensate, and it does: 'artist' is clarified as the name and 'question' as the user's question, which implies phrasing the question in natural language rather than keywords. It stops short of format examples or naming conventions for the artist string.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('look up background on one artist ... from published sources') and names the sources. The final sentence explicitly separates it from query_library, so an agent can route without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit trigger ('any question about an artist's history, members, origins, influences or career') and an explicit exclusion plus alternative ('This tool knows nothing about the user's tracks. Use query_library for those.'). Both when and when-not are covered.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

query_libraryA
Read-only

Search the user's music library and return matching tracks with their totals.

Call this before stating any fact about the library. Never estimate a count, a duration or a track name from your own knowledge, and never add numbers up yourself: use total_matching and total_duration_ms from the result, which are computed exactly. The tracks list is truncated to limit entries, so it may be shorter than total_matching.

To find a longest, shortest, highest or lowest track, pass order_by as one of longest, shortest, highest_energy, lowest_energy and read the first entry. Never rank, compare or pick a maximum out of the list yourself; the ordering is computed here.

Quote duration_display for a track and total_duration_display for a set of them. Never convert milliseconds to minutes yourself.

Energy is an estimate, not a measurement. Every track carries energy_provenance saying where its value came from, and any answer that mentions energy must say it is an estimate.

If a genre search finds nothing, known_genres lists the genre tags the library actually uses. If the user's word is another name for one of them, as rap is for hip hop, search again with that tag and say which tag you searched. Never substitute a genre that is merely related.

NameRequiredDescriptionDefault
genreNo
limitNo
artistNo
playedNo
order_byNo
released_afterNo
max_duration_msNo
min_duration_msNo
released_beforeNo

TDQS

A4.3/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already establish read-only and non-destructive behavior, but the description adds substantial behavioral context beyond that: the tracks list is truncated to limit, totals are computed exactly, ordering is computed server-side, energy is an estimate with provenance, and genre fallback is available. These details materially change how an agent should interpret and present results.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core action and key rules, and most sentences carry actionable guidance. It is somewhat long and repeats the same anti-estimation theme across multiple sentences, which costs some conciseness, but the structure remains purposeful.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, so the description appropriately explains key return fields such as total_matching, total_duration_ms, tracks, duration_display, and energy_provenance. However, for a 9-parameter tool with 0% schema description coverage, it leaves important input filters undocumented, so the overall context is only partially complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and there are 9 parameters, so the description must carry the burden of explaining them. It adds meaning for order_by values, genre fallback behavior, and limit truncation, but it does not explain artist, played, released_after, released_before, min_duration_ms, or max_duration_ms, leaving more than half of the parameters undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource: search the user's music library and return matching tracks with totals. It is immediately distinguishable from the sibling tools validate_playlist, enrich_artist, and check_feasibility, which serve different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives explicit usage rules: call before stating any fact about the library, never estimate counts or durations, use total_matching and total_duration_ms, and pass order_by for longest/shortest/highest/lowest queries. It also explains the genre fallback path and when to search again with known_genres. The guidance is unusually complete for an agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

validate_playlistA
Read-only

Check a proposed playlist against hard constraints and report every violation.

Call this before presenting any playlist to the user. Do not judge for yourself whether a playlist meets its constraints. Each violation names the offending track ids and an adjust_by amount in the constraint's own unit: negative means remove that much, positive means add that much. Act on adjust_by rather than guessing how much to change.

When describing the playlist, quote track_count and total_duration_display from this result verbatim. Never sum durations yourself and never convert milliseconds to minutes yourself.

A duration violation also carries adjust_by_display, the same amount written in minutes and seconds. Show the user that, never the millisecond figure.

Pass the same release-year bounds you gave check_feasibility, so a track outside the window is caught here too.

If the user asks for an energy level or a mood, pass target_energy between 0 and 1. It is scored, never enforced: soft_scores reports how close the playlist came, and because energy is estimated rather than measured, any answer that mentions it must say so.

NameRequiredDescriptionDefault
track_idsYes
target_energyNo
released_afterNo
released_beforeNo
required_genresNo
max_total_duration_msNo
max_track_duration_msNo
max_tracks_per_artistNo
min_total_duration_msNo

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already establish that this is a safe read (readOnlyHint=true, destructiveHint=false), and the description adds substantive behavior the annotations cannot convey: violation records carry track ids and a signed adjust_by in the constraint's unit, duration violations also carry adjust_by_display, and target_energy is scored rather than enforced. It also warns that energy is estimated and must be disclosed, which is a real behavioral constraint on downstream answers.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The most important directive (what the tool does, and call it before presenting) is front-loaded, and every subsequent paragraph carries a distinct instruction: adjust_by semantics, verbatim quoting rules, cross-tool bound reuse, and energy caveat. It is on the long side for a nine-parameter tool, but no sentence is redundant.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description has to sketch the return shape and it does: violations, adjust_by, adjust_by_display, soft_scores, track_count, total_duration_display. The remaining gap is the unmentioned constraint parameters, which an agent must guess from their names alone.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description carries the full burden. It explains target_energy well (0-1 range, scored not enforced, soft_scores output) and gives intent for released_after/released_before by tying them to check_feasibility, but required_genres, max_total_duration_ms versus min_total_duration_ms, max_track_duration_ms, and max_tracks_per_artist are never mentioned — half the parameters remain opaque.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource (check a proposed playlist against hard constraints) plus the scope of the output (report every violation). It implicitly separates itself from check_feasibility by instructing the caller to reuse the release-year bounds given to that sibling, so an agent can tell the two apart.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit temporal gating ('Call this before presenting any playlist', 'Do not judge for yourself'), an explicit cross-tool dependency ('Pass the same release-year bounds you gave check_feasibility'), and an explicit conditional trigger ('If the user asks for an energy level or a mood, pass target_energy'). Nothing is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.0
    • First observedcheck_feasibility
    • First observedenrich_artist
    • First observedquery_library
    • First observedvalidate_playlist

TDQS

A4.5/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a clearly distinct role: check_feasibility checks a brief before track selection, query_library searches local tracks, validate_playlist checks a proposed playlist, and enrich_artist retrieves external artist background. The descriptions explicitly distinguish the two check-style tools by workflow phase and data source.

Naming Consistency5/5

All four names follow a consistent snake_case verb_noun pattern: validate_playlist, enrich_artist, check_feasibility, query_library. The verbs are distinct and predictable for their actions.

Tool Count5/5

Four tools is well-scoped for a focused playlist-assistant server, with each tool covering a separate workflow stage. There is no redundant or filler tool.

Completeness4/5

The set covers feasibility checking, library search, playlist validation, and artist enrichment, which supports the core playlist-building workflow. Minor gaps remain around explicitly creating, saving, or exporting a playlist, but agents can work around this by presenting validated playlists.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers