Skip to main content
Glama

Deadwax

CI

Ein agentischer Musik-Bibliothekar über einem persönlichen Hörverlauf. Er beantwortet natürlichsprachliche Fragen zu dem, was du gehört hast, und erstellt Playlists unter harten Beschränkungen – mit einem deterministischen Validator, einer Reparaturschleife und einer Evaluationssuite, die Pass-Raten statt Pass/Fail meldet.

Als Portfolio-Projekt gebaut, das die Praxis der LLM-Entwicklung in der Produktion demonstriert: Werkzeugnutzung, Abruf, Tracing, Evaluierung und MCP.

Der interessante Teil

Die meisten LLM-Demos funktionieren, bis man sie zweimal ausführt. Deadwax ist um das herum gebaut, was beim zweiten Lauf passiert.

Das System ist entlang einer Linie geteilt: Das Modell rechnet nie. Es interpretiert Sprache, wählt Werkzeuge und verfasst Prosa. Jede arithmetische Operation, Schwellenwertprüfung und Beschränkungsentscheidung passiert in einfachem Python, das keine Ahnung hat, dass ein LLM existiert. Wenn eine Playlist eine Beschränkung verletzt, gibt der Validator nicht False zurück – er gibt einen Verletzungscode, die betreffenden Track-IDs und eine konkrete Abhilfe zurück, was der einzige Grund ist, warum eine automatisierte Reparaturschleife überhaupt funktionieren kann.

Die Machbarkeit wird vor der Generierung geprüft. Wenn ein Brief nicht erfüllt werden kann, sagt das System das. Es füllt nie auf, ersetzt nicht und degradiert nicht stillschweigend – status="infeasible" ist ein korrektes Ergebnis mit eigenen Evaluationsfällen.

Related MCP server: YouTube Music MCP Server

Architekturregeln

Keine stilistischen Vorlieben. Die Verletzung einer dieser Regeln macht den Zweck des Projekts zunichte.

  1. Das Modell rechnet nie.

  2. Werkzeugbeschreibungen sind Verhaltenskontrolle – sie sind Prompts, keine Dokumentation. Eine Änderung ist eine Verhaltensänderung und wird vor dem Mergen neu evaluiert.

  3. Verletzungen sind maschinenverwertbar: ein Code, die betreffenden IDs, eine Abhilfe. Nie ein nackter Boolean, nie nur Prosa.

  4. Die Machbarkeit wird vor der Generierung geprüft.

  5. Fehlschlag ist ein gültiges Ergebnis.

  6. Harte Beschränkungen werden gemessen und durchgesetzt. Weiche Beschränkungen werden abgeleitet und bewertet und tragen ein provenance-Feld, das jede Nachricht über sie offenlegen muss.

  7. Kein Modellaufruf ohne Trace.

Entscheidungen und ihre Abwägungen sind in docs/adr festgehalten.

Stack

Alles läuft auf einem kostenlosen Tarif. Das ist eine harte Beschränkung, keine Vorliebe.

Schicht

Wahl

Sprache

Python 3.13

Werkzeugkette

uv für Abhängigkeiten und Python selbst, ruff für Linting und Formatierung, pytest

Agent

LangChain, eingeführt in Stufe 3 und nicht früher

Modell

Google Gemini Flash, mit OpenRouter-Fallback

Speicher

SQLite über das sqlite3-Standardbibliotheksmodul

Abruf

Build-Zeit-Embeddings, Kosinus-Ähnlichkeit in einfachem Python – keine Vektordatenbank

Tracing

Langfuse

Interop

Model Context Protocol-Server

Frontend

Astro auf Cloudflare Pages – die eine JavaScript-Komponente

Die Stufen 0 bis 2 verwenden nur die Standardbibliothek – kein Framework, kein SDK, keine Abhängigkeiten. Der rohe HTTP-Aufruf wird von Hand geschrieben, bevor eine Abstraktion eingeführt wird, damit der Unterschied sichtbar ist, wenn ein Framework falsch darstellt, was es tut.

Baufortschritt

Zwölf Stufen, vier Phasen. Ein Branch und ein Squash-Merge-PR pro Stufe, damit die Historie so liest, wie der Bau tatsächlich passiert ist.

Phase

Stufe

Status

A · Grundlage

0 · Ein roher Aufruf

🔨 in Arbeit

A · Grundlage

1 · Fixture-Daten

⬜

A · Grundlage

2 · Deterministischer Kern

⬜

B · Der Agent

3 · Erste Werkzeugschleife

⬜

B · Der Agent

4 · Das Wackeln messen

⬜

B · Der Agent

5 · Evaluations-Harness

⬜ v0.5

C · Verbesserung

6 · Reparaturschleife

⬜

C · Verbesserung

7 · Adversarische Fälle

⬜

C · Verbesserung

8 · Tracing

⬜

C · Verbesserung

9 · Abruf

⬜ v0.9

D · Auslieferung

10 · Echte Daten

⬜

D · Auslieferung

11 · MCP-Server

⬜

D · Auslieferung

12 · Website und Bericht

⬜ v1.0

Ausführen

Du brauchst uv. Es installiert und verwaltet Python selbst, also ist es die einzige Voraussetzung.

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

Dann, vom Repository-Root aus:

uv sync

Das erstellt eine virtuelle Umgebung, installiert die festgelegte Python-Version aus .python-version und installiert das Projekt.

Füge einen kostenlosen Gemini-API-Schlüssel von Google AI Studio hinzu:

copy .env.example .env

Füge den Schlüssel nach GEMINI_API_KEY= ein. Dann sieh nach, welche Modelle dein Schlüssel erreichen kann, da sich die Kataloge des kostenlosen Tarifs ohne Vorankündigung ändern:

uv run scripts/raw_call.py --list

Setze eine dieser IDs in .env als GEMINI_MODEL und führe den Aufruf aus:

uv run scripts/raw_call.py

Es gibt die vollständige Anfrage und die vollständige Antwort aus, bevor die Antwort extrahiert wird. Das ist der Sinn des Skripts – die Formen sind es wert, zu wissen, bevor ein Framework sie versteckt.

Die tatsächlichen Ratenlimits deines Kontos werden unter aistudio.google.com/rate-limit angezeigt; Google veröffentlicht keine Tabelle mehr pro Modell für den kostenlosen Tarif in der API-Dokumentation.

Evaluierung

Die Evaluationssuite kommt in Stufe 5. Fälle werden von Hand geschrieben und nie generiert – wenn dasselbe Werkzeug sowohl den Code als auch die Bewertung schreibt, bedeutet die Punktzahl nichts. Punktzahlen werden als Pass-Raten über wiederholte Läufe berichtet, denn ein einzelner Pass auf einem nicht-deterministischen System ist eine Anekdote.

Jeder Commit, der einen Prompt, eine Werkzeugbeschreibung oder ein Modell ändert, trägt Vorher/Nachher-Evaluierungspunktzahlen in seiner Nachricht.

Lizenz

MIT. Siehe LICENSE.

Erstellt von 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