Autonomous AI agent for Yandex.Direct and Yandex.Metrika — with safety rails, audit trail, and a plan→confirm→execute policy.
Project description
yadirect-agent
An autonomous AI agent for Yandex.Direct that does the daily PPC chores — with a safety layer that refuses to spend money it shouldn't.
What it does
You give it a task in plain language — "pause everything with CTR below 0.5% over the last 7 days", "raise bids on the top-5 converting keywords by 20%" — and it talks to Yandex.Direct and Yandex.Metrika, plans the change, runs it through a safety pipeline, executes, and appends an audit record.
Two interchangeable transports over the same core:
- CLI —
yadirect-agent run "..."for cron or ad-hoc work. - MCP server —
yadirect-agent mcp servefor Claude Desktop and Claude Code. Same tools, same safety, different shell.
The problem it solves
Day-to-day PPC management is dozens of small, repetitive decisions on the same handful of signals (CTR, CPA, Quality Score, query drift). They eat attention and they're easy to drop. Handing them to "just an LLM with API keys" is how you wake up to a drained budget.
This agent does the chores and treats spending as the dangerous operation it is: every mutating call is gated, every change is auditable, defaults refuse to do anything irreversible without a human in the loop.
Status
Pre-alpha. The shipped scope, the queue, and the discovered tech debt all
live in docs/BACKLOG.md — that's the single
source of truth, README will not try to mirror it. Roadmap by milestone:
docs/TECHNICAL_SPEC.md.
At a coarse level: reads, safe pauses, gated mutations (resume / budget /
bids via apply-plan), full safety pipeline (7 kill-switches +
plan→confirm→execute + audit + staged rollout), CLI and MCP work today.
Real Wordstat, A/B testing, Metrika reporting and alerts don't yet.
Quickstart
Requires Python 3.11+.
End user (recommended — once on the host machine):
pip install yadirect-agent # or: pipx install yadirect-agent
yadirect-agent install-into-claude-desktop # wires it into Claude Desktop
# Restart Claude Desktop, then in chat:
# "помоги настроить Яндекс.Директ-агент"
If you prefer the CLI without Claude Desktop:
pip install yadirect-agent
cp /path/to/.env.example .env # fill tokens; keep YANDEX_USE_SANDBOX=true
cp /path/to/agent_policy.example.yml agent_policy.yml
yadirect-agent --version
yadirect-agent run "list all campaigns in sandbox"
Contributor / pre-release (current path):
git clone git@github.com:Kozharina/yadirect-agent.git
cd yadirect-agent
make install # venv + dev deps via uv
cp .env.example .env # fill tokens; keep YANDEX_USE_SANDBOX=true
cp agent_policy.example.yml agent_policy.yml # set account_daily_budget_cap_rub
make check # lint + type + tests must be green
yadirect-agent run "list all campaigns in sandbox"
Driving it from Claude Desktop / Claude Code:
docs/OPERATING.md.
Safety in one screen
Four independent layers. Any one of them can refuse the operation.
- Sandbox by default.
YANDEX_USE_SANDBOX=truehitsapi-sandbox.direct.yandex.comand cannot move real money. Flipping it is a deliberate human action, not something the agent can talk you into. - Plan → confirm → execute. Every mutating call is serialised into
an
OperationPlan, run through the policy pipeline (budget cap, max-CPC, required negatives, QS guard, budget-balance shift, conversion integrity, query drift), and only then dispatched. The policy lives inagent_policy.ymland cannot be overridden from the model's context. - Audit JSONL. Every action — agent and operator — is appended to
logs/audit.jsonlwith atrace_id, request/response shapes, and a reversibility marker. Append-only. Secrets are stripped at the sink. - Staged rollout.
shadow → assist → autonomy_light → autonomy_fullinagent_policy.yml. Promotion is an explicityadirect-agent rollout promotecall that itself gets audited.
The deeper version: docs/TECHNICAL_SPEC.md §M2.
Reporting a vulnerability: SECURITY.md.
Commands
yadirect-agent run "<task>" # one-shot agent run
yadirect-agent chat # interactive REPL
yadirect-agent list-campaigns [--state] # direct call, no model (debug)
yadirect-agent plans list | show <id> # inspect pending plans
yadirect-agent apply-plan <id> # operator approval — actually executes
yadirect-agent rollout status | promote # autonomy stage transitions
yadirect-agent mcp serve [--allow-write] # MCP stdio server
yadirect-agent doctor # environment diagnostics
Where to look next
| You want to… | Read |
|---|---|
| Use it from Claude Desktop / Claude Code | docs/OPERATING.md |
| Understand the layers and what depends on what | docs/ARCHITECTURE.md |
| See what's queued, blocked, in tech debt, done | docs/BACKLOG.md |
| Read the milestone roadmap | docs/TECHNICAL_SPEC.md |
| Contribute code | docs/CODING_RULES.md, docs/TESTING.md, docs/REVIEW.md |
| Know how Claude Code itself behaves in this repo | CLAUDE.md |
| Report a vulnerability | SECURITY.md |
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yadirect_agent-0.2.0.tar.gz.
File metadata
- Download URL: yadirect_agent-0.2.0.tar.gz
- Upload date:
- Size: 526.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d62ca795b8b29fa284893a5b4f7b7e319a8229de1d9b586487b3cdbd97d3f46
|
|
| MD5 |
efd652caea58a1d5954db44375b5db54
|
|
| BLAKE2b-256 |
4155cfbb946312b7790c3c73a15cb270c50dd884b7341c3e69ec2b085eda2f91
|
Provenance
The following attestation bundles were made for yadirect_agent-0.2.0.tar.gz:
Publisher:
release.yml on Kozharina/yadirect-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yadirect_agent-0.2.0.tar.gz -
Subject digest:
5d62ca795b8b29fa284893a5b4f7b7e319a8229de1d9b586487b3cdbd97d3f46 - Sigstore transparency entry: 1450609218
- Sigstore integration time:
-
Permalink:
Kozharina/yadirect-agent@8179c2ec9e48d23201e161118345ac9fda58ff27 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Kozharina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8179c2ec9e48d23201e161118345ac9fda58ff27 -
Trigger Event:
push
-
Statement type:
File details
Details for the file yadirect_agent-0.2.0-py3-none-any.whl.
File metadata
- Download URL: yadirect_agent-0.2.0-py3-none-any.whl
- Upload date:
- Size: 235.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86208fbf0c5077809a40b518ed8b651b28b3db25c29af8bbe6e80b371b52f744
|
|
| MD5 |
30aba64a3eaa319e63272cfadc176c25
|
|
| BLAKE2b-256 |
efdaf0e4155f97266a6058e50dbcb06b69edc4d7f2f54900b62395f063f13001
|
Provenance
The following attestation bundles were made for yadirect_agent-0.2.0-py3-none-any.whl:
Publisher:
release.yml on Kozharina/yadirect-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yadirect_agent-0.2.0-py3-none-any.whl -
Subject digest:
86208fbf0c5077809a40b518ed8b651b28b3db25c29af8bbe6e80b371b52f744 - Sigstore transparency entry: 1450609495
- Sigstore integration time:
-
Permalink:
Kozharina/yadirect-agent@8179c2ec9e48d23201e161118345ac9fda58ff27 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Kozharina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8179c2ec9e48d23201e161118345ac9fda58ff27 -
Trigger Event:
push
-
Statement type: