Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ Works with RateCue 0.2.0 and earlier.

### Added

- **Hosted models.** The agent can run against a hosted OpenAI-compatible endpoint as well as a private one. When an endpoint rejects a request option it does not support (`max_tokens`, `temperature`, the chat-template option that turns thinking off), the agent drops or renames that option and retries at once. When an endpoint refuses the API key, the agent stops instead of retrying.
- `LLM_AUTH=anthropic-login`. The agent takes a short-lived token from the Anthropic CLI's login (`ant auth login`) and renews it as it expires, so no key is stored in its settings.
- When a provider reports that the account has no credit, the agent stops as it does for a refused key, instead of retrying.
- `LLM_TEMPERATURE`. Unset, the agent sends a temperature of 0.4 to a model on its machine or network and none to a hosted one, since current hosted models accept only their own default. `none` sends no temperature anywhere.
- Token use. Each cycle's log line carries the input and output tokens the endpoint reported, and the report states the total for its knowledge base. On a hosted model that is the bill.
- `model_smoke_test.py` asks a hosted endpoint the way it accepts: Anthropic's model list with its own key header, no temperature or chat-template option, and room for a model that thinks before it answers.
- `LOG_SCOPE`. With `playback`, a `log show` result reaches the model with only Music's playback and audio subsystems and without URL query strings. Unset, it is `playback` for an endpoint that is not on this machine or a private network, and `all` otherwise.
- Track titles are replaced in Music's `mediaFormatinfo` record: by the collector before it stores a log line, by the gate in every result, and by the agent in everything the Mac returns. macOS only writes the title there when a log-privacy profile is installed.
- `queue_prediction_metrics`: Music's own advance notice of a queue item's format, when it queues the item and when it starts buffering it, scored against the item's first decoder report. A database that predates the table is scored once from the log lines it already holds.
- The gate allows RateCue's read-only `decoder-status` command.
- The collector reads the displayed format from the explicit fields RateCue 0.2 publishes, and understands both the new (`96 kHz / 24-bit`) and the earlier (`96k / 24`) menu title.
- A license (GPL-3.0-only), a notice with attribution and dependency licenses, contribution guidelines, a code of conduct, issue and pull request templates, SPDX identifiers in every source file, and this changelog.

### Changed

- The `queued` stage of `queue_predictions` is read from Music's variant-selection record, whose fields are public, instead of the "highest eligible alternate" record, whose variant needs a log-privacy profile.
- `track_formats` selects the decoder report by when it was logged, which is the audible boundary, instead of by when Music began buffering the item.
- `ratecue_*` is the last snapshot taken while the track was current.
- A decoder report with a rate and no depth is recorded as a lossy rendition. For such a play, displaying no depth is a `match` and displaying one is a `MISMATCH`.
Expand All @@ -29,5 +38,5 @@ Works with RateCue 0.2.0 and earlier.

First public release: the collector, the read-only SSH gate, the research agent, the three-way comparison, and best-effort sequence prediction metrics.

[0.2.0]: https://github.com/troylefevre65/StreamWatch/compare/df856e0...main
[0.2.0]: https://github.com/troylefevre65/StreamWatch/releases/tag/v0.2.0
[0.1.0]: https://github.com/troylefevre65/StreamWatch/commits/df856e0
14 changes: 14 additions & 0 deletions MODEL-SELECTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ changing the agent to fit whichever model happens to be loaded. A private
OpenAI-compatible host is used for evaluation; a separate appliance remains the collector and
RateCue appliance.

## Switching models

The agent takes five settings from its environment file: `LLM_BASE_URL`, `LLM_API_KEY`, `LLM_MODEL`, `NO_THINK` and `CYCLE_PAUSE`, plus `LOG_SCOPE` for what it may send and `LLM_AUTH` for how it signs in (`key`, or `anthropic-login` to use the Anthropic CLI's login with no stored key). Any OpenAI-compatible endpoint works: Ollama, LM Studio, a llama.cpp server, or a hosted API such as Claude (`https://api.anthropic.com/v1`), OpenAI or OpenRouter. Change them and restart the agent.

When the agent runs on the Mac beside RateCue, RateCue does this for you. **Advanced Diagnostics → Developer Mode → Agent Model** keeps a list of models, holds API keys in the Keychain, rewrites those settings when you select one, and restarts the agent. `RateCue developer model list | add | use | models | remove` is the same thing from a shell. It does not touch `AGENT_DB` or `REPORT_PATH`, so a switched model continues the same knowledge base; give a comparison run its own database as described under [Prepare a repeatable evaluation](#prepare-a-repeatable-evaluation).

A hosted model is sent no sampling temperature unless `LLM_TEMPERATURE` sets one, and a model that thinks before it answers needs room for that in `LLM_MAX_TOKENS`: 2048 suits a small local model with thinking turned off, and 8192 is a safer start for a hosted one. `llm-box/model_smoke_test.py` works against either kind. Through Anthropic's OpenAI-compatible endpoint there is no prompt caching, and Anthropic describes that endpoint as meant for testing and comparison.

Each cycle's log line reports the tokens it used, and the report carries the running total, so the cost of a hosted run is measured and not guessed.

Otherwise the agent sends each endpoint the same request and adjusts once if it is refused: it switches `max_tokens` to `max_completion_tokens`, stops sending a temperature, or stops sending the chat-template option behind `NO_THINK`, whichever the endpoint names. A refused key stops the agent.

A hosted model changes two things that a local one does not: the agent's working context leaves your network, and every cycle costs money. Read [Hosted models](SECURITY.md#hosted-models) first. The rest of this guide is about choosing and proving a local model, and its scorecard applies to a hosted one unchanged.

## Current host and baseline

A private evaluation host can serve llama.cpp at an operator-configured endpoint:
Expand Down
2 changes: 2 additions & 0 deletions OPERATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ This mode is for a remote-model test while a dedicated LLM box is being built. I
chmod 600 ~/streamwatch/agent.env
```

To use a different model later, change those settings and restart the agent, or select one in RateCue under **Developer Mode → Agent Model**. For an endpoint outside your network, read [Hosted models](SECURITY.md#hosted-models) first; the agent then defaults to `LOG_SCOPE=playback`.

6. For a foreground smoke test, source that environment and run the checked-out `llm-box/agent.py` with the venv. For unattended use, wrap those commands in a `~/streamwatch/run-agent.sh` script and a LaunchAgent that logs under `~/streamwatch/`. Do not put the LaunchAgent plist in the Git repository; it contains local paths.
7. Confirm the forced-key query, OpenAI tool call, collector smoke test and completed agent cycle before leaving it unattended.

Expand Down
21 changes: 20 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,28 @@ The Mac's forced SSH command is an execution boundary for the agent, not complet
- Keep the remote endpoint HTTP on a trusted LAN or provide TLS; credentials sent over cleartext should be treated as equivalent to public on that network.
- Limit GitHub tokens to read-only public-repository access.

## Hosted models

A model on the agent's machine or a private network keeps the agent's working context there. A hosted endpoint receives it, and bills for it. Decide that deliberately.

What a hosted endpoint is sent: the research prompt, playback times and formats, audio device details, the results of the agent's database queries and Mac commands, RateCue and other public source code, search results and the web pages the agent reads.

What it is not sent:

- Track titles, artists, albums and persistent identifiers. The gate's SQL authorizer denies those columns, and the title in Music's `mediaFormatinfo` log record is replaced by the collector, the gate and the agent.
- Most of Music's log. With `LOG_SCOPE=playback`, which is the default for any endpoint that is not local, the agent passes on only the `com.apple.coremedia`, `com.apple.coreaudio` and `com.apple.audio*` subsystems of a `log show` result and removes URL query strings. This matters on a Mac with a log-privacy profile installed: there, Music's store, account and network subsystems log account identifiers and addresses in the clear. In a 20-minute sample on such a Mac the playback and audio subsystems held no URL and no account identifier in 10,544 lines; the other subsystems held both.

This filter is the agent's, so it protects only an agent new enough to have it. RateCue checks for it before it will select a hosted model. `LOG_SCOPE=all` with a hosted endpoint sends all of Music's log and is logged as a warning at start.

It is a filter on known fields, not a guarantee. Playback times are a listening history without titles, and a line in an allowed subsystem could carry something unexpected. If that is unacceptable, use a local model.

For Claude, `LLM_AUTH=anthropic-login` keeps any long-lived secret out of the agent's settings: the agent asks the Anthropic CLI for the access token of its login, which lasts hours, and asks again as it expires. The login itself is stored by the CLI under `~/.config/anthropic`, readable only by its owner. Anthropic intends that login for development on your own machine; a server should use an API key or workload identity federation.

Use `https` for any endpoint outside a private network. Give a hosted provider a key with a spending limit where the provider offers one, and set `CYCLE_PAUSE` high: it is the only throttle on what an always-on agent spends. With the default limits one cycle is at most 14 model calls of about 12,000 input and 4,096 output tokens each.

## Private data

The Mac database intentionally retains some local operator metadata so the collector can detect track transitions. The LLM-facing view and SSH authorizer omit track and device identity. Raw audio-log messages, device transport/rate, RateCue status and playback timing are still sensitive operational data.
The Mac database intentionally retains some local operator metadata so the collector can detect track transitions. The LLM-facing view and SSH authorizer omit track and device identity. Raw audio-log messages, device transport/rate, RateCue status and playback timing are still sensitive operational data. `log show` through the gate returns whatever Music logged in the requested window; see [Hosted models](#hosted-models) for what an agent with a hosted endpoint passes on.

External search is blocked when a query contains obvious local paths, IP addresses, UUID-like IDs or email addresses. This is defense in depth, not perfect data-loss prevention. Do not paste private diagnostics into a model or public issue without review.

Expand Down
Loading
Loading