From 8c6cbdf0028a02335e6cf7c56a6df6be73948f20 Mon Sep 17 00:00:00 2001 From: Wolf Date: Sat, 3 Oct 2026 22:48:46 +0200 Subject: [PATCH] Give an agent a soft profile of likes and dislikes and take the must-haves off the form (wp-likes) Add agents.like_text (migration 30) beside avoid_text, now shown as "What I don't like". The judge reads both under and , its career rubric judges against the prompts, the likes and the dislikes, and FORMAT 3 makes earlier judgements be made again. The form drops the must-haves box and no longer sends must_text, so a stored one is kept and still caps career in code. Co-Authored-By: Claude Sonnet 5.5 --- app/jobs/judge.py | 30 ++++++++++++--------- app/models.py | 11 +++++--- app/static/agents.js | 24 ++++++++++------- app/storage/schema.py | 22 +++++++++++++--- app/storage/store.py | 16 +++++++----- app/templates/settings/agents.html | 8 +++--- app/web/api.py | 6 +++-- docs/decisions.md | 2 +- tests/test_companies.py | 4 +-- tests/test_cv_feed.py | 6 ++--- tests/test_cv_fields.py | 42 ++++++++++++++++++++++-------- tests/test_dupes_storage.py | 2 +- tests/test_fetch_terms.py | 2 +- tests/test_judge.py | 17 +++++++++++- tests/test_overrides.py | 2 +- tests/test_prep.py | 2 +- tests/test_remote.py | 4 +-- tests/test_storage.py | 19 +++++++------- 18 files changed, 144 insertions(+), 75 deletions(-) diff --git a/app/jobs/judge.py b/app/jobs/judge.py index d04d9ed..e76b40a 100644 --- a/app/jobs/judge.py +++ b/app/jobs/judge.py @@ -15,7 +15,7 @@ is guessed from ad text, the second is what the gates do. The work is pairs, `(agent, role)`: an enabled agent with a CV, and a role among its best ungated scores as deep and as low as its own `limits` say (`judge_top`, `judge_min`) with some text, that has no judgement yet, or one -read from another CV, prompts, avoid or must text or role text than today's +read from another CV, prompts, like, avoid or must text or role text than today's (`input_key`). A pair is named by the composite key `":"`, which is what `desk.modeltask` hands round as a uid, so `desk/` is untouched. A batch holds one agent's pairs, since the profile is in the system prompt; @@ -59,16 +59,18 @@ EXCERPT = 8000 #: The format of what the judge asks and stores, part of `input_key`: a #: change to the prompt's contract makes every judgement be made again. #: 2: the verdict on each numbered must-have (`musts`), the cap in code. -FORMAT = 2 +#: 3: what the person likes (`like_text`) beside what they do not, and the +#: career rubric reading both. +FORMAT = 3 #: How many strengths and gaps are kept, and how long each may be. MOST, LONGEST = 3, 300 SYSTEM = """You judge job postings for one person: how well each fits their CV and what they want. -Below the rules is the person: their CV, what they want and what excites -them, what drains them and environments to avoid, and their must-haves and -deal-breakers. Each item is one posting with a key, its title, company, place +Below the rules is the person: their CV, what they want, what they like and +what they do not like (the work, the workplace, situations), and their +must-haves and deal-breakers when they gave any. Each item is one posting with a key, its title, company, place and text. Answer one judgement per item. Score three dimensions, each 0 to 100: @@ -79,11 +81,12 @@ Score three dimensions, each 0 to 100: literal job title, and on its level. 80-100 direct experience in the same domain and role type; 60-79 related, with transferable skills clear; 40-59 adjacent, the person would need to make the case; 0-39 unrelated. -- career: against what the person wants and what drains them. 80-100 strongly +- career: against what the person wants (the prompts), what they like and + what they do not like. 80-100 strongly aligned with their direction, with clear growth; 60-79 a good role, partly aligned; 40-59 a decent job that does not build toward their goals; 0-39 a - dead end or a step backwards. Judge whether the tasks would energise them, - not only whether they could do them. + dead end or a step backwards. Judge whether the tasks and the setting would + energise them, not only whether they could do them. Their must-haves and deal-breakers are numbered M1, M2 and so on. Give a verdict on every one of them, in `musts`, for each item: @@ -173,10 +176,10 @@ def _text(row: Any) -> str: def input_key(agent: Agent, text: str) -> str: """A hash of everything a judgement reads: the CV, the prompts, the - avoid and must texts, and the role's text as sent. A judgement stored + like, avoid and must texts, and the role's text as sent. A judgement stored under another key is read again.""" blob = json.dumps([FORMAT, agent.cv_text, [[p.name, p.text] for p in agent.prompts], - agent.avoid_text, agent.must_text, text], ensure_ascii=False) + agent.like_text, agent.avoid_text, agent.must_text, text], ensure_ascii=False) return hashlib.sha1(blob.encode()).hexdigest()[:16] @@ -227,9 +230,12 @@ def system(agent: Agent) -> str: for p in agent.prompts if p.text.strip()) if wants: parts.append(f"\n\n{wants}\n") + if agent.like_text.strip(): + parts.append("\n\n" + f"{agent.like_text.strip()}\n") if agent.avoid_text.strip(): - parts.append("\n\n" - f"{agent.avoid_text.strip()}\n") + parts.append("\n\n" + f"{agent.avoid_text.strip()}\n") if musts := must_lines(agent.must_text): lines = "\n".join(f"M{n}: {line}" for n, line in enumerate(musts, start=1)) parts.append(f"\n\n{lines}\n") diff --git a/app/models.py b/app/models.py index d08694e..ec5cdfa 100644 --- a/app/models.py +++ b/app/models.py @@ -1553,10 +1553,12 @@ class Agent(Model): union over the enabled agents, and an agent with none means no board is narrowed by words. They decide what is fetched, not what ranks. - `cv_text`, `cv_languages`, `avoid_text` and `must_text` are what - `judge` reads a role against: the CV, the languages it states with a - level, what drains the person, and their must-haves and deal-breakers - (soft, read by the model only; a hard rule is a gate). An agent without + `cv_text`, `cv_languages`, `like_text`, `avoid_text` and `must_text` are + what `judge` reads a role against: the CV, the languages it states with + a level, what the person likes and does not like (the work, the + workplace, situations; both feed the career score), and their + must-haves and deal-breakers (set through the API only, not on the + form; soft, read by the model only; a hard rule is a gate). An agent without a CV is not judged, and one without languages flags none (`language_flag`).""" @@ -1569,6 +1571,7 @@ class Agent(Model): fetch_terms: FetchTerms = [] cv_text: str = "" cv_languages: CvLanguages = [] + like_text: str = "" avoid_text: str = "" must_text: str = "" enabled: bool = True diff --git a/app/static/agents.js b/app/static/agents.js index 2ceca39..c543a40 100644 --- a/app/static/agents.js +++ b/app/static/agents.js @@ -20,12 +20,14 @@ * * The CV fieldset holds what the judge stage reads a role against: the CV as * text (typed, or read from a .md/.txt file by the browser), the languages it - * states as rows of a code and a level, and the avoid and must-have texts. - * The must-have text is one must-have per line, which the judge answers one - * verdict each; a broken one caps career at 39 in code (the hint in - * settings/agents.html says so). - * Every save sends all four, and the card's switch re-posts the row as the - * server gave it, so neither drops them. + * states as rows of a code and a level, and the two soft texts, what the + * person likes and what they do not like (the work, the workplace, + * situations), which the judge reads for the career score. The must-have text + * is no longer on the form: a save leaves `must_text` out, so the stored one + * is kept (it is set through the API, and still caps career at 39 in code + * when the judge reports one broken). + * Every save sends the CV, languages and the two texts, and the card's switch + * re-posts the row as the server gave it, so neither drops them. * * Every request goes through `api()` from app.js, so a failure is one toast * carrying the server's own sentence. @@ -502,12 +504,14 @@ } // The CV on a card: whether the judge has one to read roles against, and - // the languages it states, as "da fluent, en native". + // the languages it states, as "da fluent, en native", and whether the + // likes and dislikes are written. function cvLine(row) { const langs = row.cv_languages || []; const said = langs.length ? `Languages: ${langs.map((l) => `${l.language} ${l.level}`).join(", ")}.` : "No languages stated."; const has = Boolean((row.cv_text || "").trim()); - return el("p", "agent-terms", has ? `CV set. ${said}` : `No CV, so roles are not judged against one. ${said}`); + const soft = `Likes ${(row.like_text || "").trim() ? "set" : "not set"}, dislikes ${(row.avoid_text || "").trim() ? "set" : "not set"}.`; + return el("p", "agent-terms", `${has ? "CV set." : "No CV, so roles are not judged against one."} ${said} ${soft}`); } // A prompt as a row: its name and Remove on a line, its text under them. @@ -646,8 +650,8 @@ // is cleared in the store. const cvText = $("#a-cv-text", f); cvText.value = row ? row.cv_text || "" : ""; + $("#a-like-text", f).value = row ? row.like_text || "" : ""; $("#a-avoid-text", f).value = row ? row.avoid_text || "" : ""; - $("#a-must-text", f).value = row ? row.must_text || "" : ""; const languages = []; const dropLanguage = (node) => { languages.splice(languages.findIndex((l) => l.node === node), 1); @@ -898,8 +902,8 @@ fetch_terms: read.terms(), cv_text: $("#a-cv-text", f).value, cv_languages: cvLanguages, + like_text: $("#a-like-text", f).value, avoid_text: $("#a-avoid-text", f).value, - must_text: $("#a-must-text", f).value, // Saving an agent means it is wanted, so a new one starts on; the // card's switch is where an existing one is switched. enabled: row ? row.enabled : true, diff --git a/app/storage/schema.py b/app/storage/schema.py index bf8786a..4ae5384 100644 --- a/app/storage/schema.py +++ b/app/storage/schema.py @@ -328,9 +328,10 @@ END; -- as JSON: a key it lacks means the `Limits` default. fetch_terms is a JSON -- list of words that narrow what big boards send (app/jobs/reach.py); empty -- means no narrowing. cv_text, cv_languages (a JSON list of {language, --- level}), avoid_text (what drains) and must_text (must-haves and --- deal-breakers) are what judge reads a role against; an agent with no CV --- is not judged. +-- level}), like_text (what they like: the work, the workplace, situations), +-- avoid_text (what they do not like) and must_text (must-haves and +-- deal-breakers, set through the API only) are what judge reads a role +-- against; an agent with no CV is not judged. CREATE TABLE IF NOT EXISTS agents ( id INTEGER PRIMARY KEY, name TEXT NOT NULL UNIQUE, @@ -343,7 +344,8 @@ CREATE TABLE IF NOT EXISTS agents ( cv_text TEXT NOT NULL DEFAULT '', cv_languages TEXT NOT NULL DEFAULT '[]', avoid_text TEXT NOT NULL DEFAULT '', - must_text TEXT NOT NULL DEFAULT '' + must_text TEXT NOT NULL DEFAULT '', + like_text TEXT NOT NULL DEFAULT '' ); -- What an agent looks for, as several named texts in order; a role's fit is @@ -707,6 +709,10 @@ UPDATE roles SET seniority = COALESCE(NULLIF(seniority_model, ''), # keep their numbers; the judge reads them again (judge.FORMAT). (29, "role_judgements.musts and broken: the verdict on each must-have, and how many are " "broken", lambda conn: _add_musts(conn)), + # A Python step: it adds the column only where it is missing. The judge + # reads every role again (judge.FORMAT). + (30, "agents.like_text: what the person likes, beside what they do not like", + lambda conn: _add_like_text(conn)), ) #: What a file created from `SCHEMA` today is already at. @@ -1047,6 +1053,14 @@ def _add_musts(conn: sqlite3.Connection) -> None: conn.execute(f"ALTER TABLE role_judgements ADD COLUMN {column} {ddl}") +def _add_like_text(conn: sqlite3.Connection) -> None: + """Migration 30's step: `agents.like_text`, empty on every agent. Runs + twice without harm.""" + columns = {r[1] for r in conn.execute("PRAGMA table_info(agents)")} + if "like_text" not in columns: + conn.execute("ALTER TABLE agents ADD COLUMN like_text TEXT NOT NULL DEFAULT ''") + + def _add_all_roles(conn: sqlite3.Connection) -> None: """Migration 21's step. The column; the tag for every company that is a favourite of any agent, since favourite no longer widens what a pull diff --git a/app/storage/store.py b/app/storage/store.py index 1c5e5e3..217c57f 100644 --- a/app/storage/store.py +++ b/app/storage/store.py @@ -2093,13 +2093,14 @@ class Store: cv_text: str | None = None, cv_languages: Sequence[CvLanguage] | None = None, avoid_text: str | None = None, - must_text: str | None = None) -> Agent: + must_text: str | None = None, + like_text: str | None = None) -> Agent: """Create an agent, or with `agent_id` replace that one's fields and prompts. Without `prompts`, a non-empty `intent` is its one prompt, named after the agent. Without `fetch_terms` an update keeps the stored ones and a new agent has none, so a caller that does not know them (the CLI's prompt edit) loses none; `cv_text`, `cv_languages`, - `avoid_text` and `must_text` are kept the same way. A prompt whose text is + `like_text`, `avoid_text` and `must_text` are kept the same way. A prompt whose text is unchanged keeps its cached vector, whatever its name or place, so an edit re-embeds only the prompts it changed. A save gives every role `judge` gave up on for the agent its tries back, since what it is @@ -2120,16 +2121,18 @@ class Store: (limits or Limits()).model_dump_json(), int(enabled), terms, None if cv_text is None else cv_text.strip(), spoken, None if avoid_text is None else avoid_text.strip(), - None if must_text is None else must_text.strip()) + None if must_text is None else must_text.strip(), + None if like_text is None else like_text.strip()) try: with self.transaction() as conn: if agent_id is None: agent_id = conn.execute( """INSERT INTO agents (name, gates, weights, limits, enabled, fetch_terms, cv_text, cv_languages, avoid_text, - must_text, created_at) + must_text, like_text, created_at) VALUES (?,?,?,?,?,COALESCE(?, '[]'),COALESCE(?, ''), - COALESCE(?, '[]'),COALESCE(?, ''),COALESCE(?, ''),?)""", + COALESCE(?, '[]'),COALESCE(?, ''),COALESCE(?, ''), + COALESCE(?, ''),?)""", (*fields, self.now())).lastrowid elif not conn.execute( """UPDATE agents SET name=?, gates=?, weights=?, limits=?, enabled=?, @@ -2137,7 +2140,8 @@ class Store: cv_text=COALESCE(?, cv_text), cv_languages=COALESCE(?, cv_languages), avoid_text=COALESCE(?, avoid_text), - must_text=COALESCE(?, must_text) + must_text=COALESCE(?, must_text), + like_text=COALESCE(?, like_text) WHERE id=?""", (*fields, agent_id)).rowcount: raise KeyError(agent_id) diff --git a/app/templates/settings/agents.html b/app/templates/settings/agents.html index 7771eb3..614aef4 100644 --- a/app/templates/settings/agents.html +++ b/app/templates/settings/agents.html @@ -93,11 +93,11 @@ A two-letter code such as en or da, and how well. Roles that ask for a language you lack, or a level above yours, get a warning on Roles; a role that names one of yours as a plus gets a star. With none, no role is flagged. Suggest languages reads them from the CV with one model call and replaces the rows above; nothing is saved until Save. -