Agent (anchor.agent)¶
Runs a request end to end: plan, execution, effect checks, replanning and end.
python -m anchor.agent --profile ollama-small --url eval/fixtures/registration_en.html "Register Maria Silva in the IT department and save the registration"
| Option | Meaning |
|---|---|
request (positional) |
What to do, in natural language (Portuguese or English). |
--profile |
Model profile in llm_profiles.json (e.g. ollama-small, ollama-medium). Required. |
--url |
The site's link, or the path of a local .html file. Required. |
--memory |
File of the choice memory. Default: memory/agent.json. |
--browser-profile |
Folder of a persistent browser profile, for systems with login (e.g. profiles/user_001). |
--max-attempts |
Failures before the run is cancelled. Default: 3. |
--vision |
When the other checks doubt a step (a field that does not show the value, a click with no visible effect in the page's code, an expected text that did not appear), asks the model about a screenshot, scaled to 640 pixels. It can only confirm a doubted step, never fail one that worked. Slower: about 5 s per question with the 4B model and 9 s with the 9B, on the test machine. The model must have the vision capability. |
--allow-sensitive |
Does not ask before sensitive actions. By default, before deleting, saving or submitting, sending, paying, downloading or uploading, or acting on your account (following someone, connecting, liking, commenting, sharing, subscribing, inviting), the agent shows the element and asks; a denial stops the run. |
--output-dir |
Where tables and lists read by the agent are saved (one CSV file each) and where downloaded files go, never overwriting a file. Default: output. |
--lang |
Interface language: en (default) or pt. Overrides ANCHOR_LANG. |
--prompt-language |
Planner prompt language: pt (default, the measured one), en, or auto (follows the request). |
Hidden content. When a step's target is not on the page, the agent looks for what may hide it, a
"Show more" / "Mostrar mais" button or a collapsed section (aria-expanded="false"), opens it and
tries the step again, before any replan. Only controls that say so, with no action verb and nothing
sensitive (never "Save and show more"), at most two per step. A step that names what its element is
about ("Add to cart of the UltraBook 14") is not done on a lookalike when that name is not on the
page: the agent reveals hidden content first, and otherwise the step is "not found".
Cookie banners. When a cookie or consent banner is in the way of a step, the agent declines it, with the most restrictive option the banner offers ("Recusar", "Reject all", "Only essential"), and says so: before the step, when the step's element is covered, and otherwise after the step fails, which is then tried again. It never accepts cookies on its own: a banner with no way to decline is left alone, and so is any other layer (a promotion, a notice); when such a layer covers a "Show more", the planner is told to close it first.
Iframes. Elements inside an iframe (an embedded form, a payment or newsletter widget, even from another site) are found and used like the page's own: the resolver reads the page and then each iframe, and the effect check, the password field, tables and value texts look inside them too. Two limits: choosing an element by clicking on it (when the agent asks) only works on the page itself, inside an iframe you choose it by number; and the remembered choices' fallback (the saved CSS path) only looks at the page itself.
New tabs. When a step opens a new tab (a link with target="_blank", a button that opens a
window), the agent moves to it and replans from there; when the tab it is working in closes by
itself (a payment or login window), it goes back to the last tab still open. Only a tab the step
opened is followed: a tab the page opens on its own between steps (an ad) is not. Saved automations
close the tabs a run opened, so the next spreadsheet row starts from the automation's own tab.
Only what was asked. The agent does not send, save, confirm, pay, export or print what the request did not ask for: such a click is blocked, and the planner is told so. It is asked for when the request has a verb for it ("salve", "envie", "pague"; for exporting, a verb or a word for a file), or when the request and the button are about the same thing ("reserve a sala" and "Reservar sala"). So "attach the resume" does not end with the application sent; "attach the resume and send the application" does. Destructive actions (deleting, cancelling) have their own barrier. Acting on your account on a social site (following someone, connecting, liking, reacting, commenting, sharing, reposting, subscribing, inviting) is blocked too unless the request has a verb for it ("siga", "curta", "share"): a request about the same person does not ask to follow them. "Seguir" alone, or "Seguir para o pagamento", is going on, not following.
Goals and the end check. A goal of the plan is met by its last planned step (a search is not met by the click that opens the search box), never by a step that led to a login page. Before saying a request is done, the agent checks that what it asks to finish was finished: a search must be sent (a click or Enter) after its term was typed; "confirm whether…" is a check, not a click on Confirm.
The site's own pop-ups. An alert is accepted and what it says reaches the planner; a question ("Are you sure?") is always answered no, since the agent never confirms on its own. A click with no visible change waits for what the click itself scheduled on the page (up to 8 s) before it counts as "no effect". A click on an element that something covers fails after 10 s, and the planner is told what covers it.
Logging in. The agent never types a password: a fill of the plan that would land on a password
field is not done. A request that seems to contain a password ("senha: ...", "password ...") is
refused before anything reaches the model. When a task needs a login (the request asks to log in,
the plan reaches a password field, or nothing can be planned on a page that asks for one), ANCHOR
first uses a login saved for exactly that page's site (saved in the interface, Settings → Saved
logins; the password is in Windows' Credential Manager): its own code types it, only into a
password field and only on that site, and the model never sees it. With no saved login, two for the
site, or one that does not get in, the agent asks in the terminal: log in (or fill in the password)
yourself in the browser window and press Enter, or q to cancel. If the page still shows an empty password field, it asks again. A step that
leads to a login page (a "Star" that asks to sign in first) does the same, and the plan starts again
from the page after the login. With --browser-profile, the session is kept for the next runs.
Sending files. A request to send a file ("Attach the resume C:/Users/ana/cv.pdf") is planned
as an upload step: the agent puts the file in the file field, or clicks the button that opens the
file chooser ("Attach resume") and picks it there. The path must be written in the request (or in
the automation's notes or parameters): the model never chooses a file from your computer, and a
plan with a path that is not in the request is refused. A path that does not exist stops the run
with a message, before anything on the page is touched. Every upload is a sensitive action, so it
asks first. In a saved automation, a parameter can give a different file per spreadsheet row
(--param file=..., or a file column).
Downloading files. A request to download a file ("Download the sales report") is planned as
a download step: the agent clicks the button or link and waits for the file, which it saves in
the output folder with the name the site suggests (report (2).csv if the name is taken). Every
download is a sensitive action, whatever the button says, so it asks first. A click that
downloads nothing fails, and the planner is told so.
Reading data from a page. A request to read, copy or export a table or a list ("Export the
sales by region table") is planned as an extract_table step: the agent finds the table or list
by its caption, title or column headers, and saves it as a CSV file, in UTF-8 with the
separator of the interface language (; in Portuguese, so Excel opens it in columns; , in
English). Menus, headers and footers are never taken as data. When the request could mean more
than one table, the agent does not guess: it tells the planner their names, and the planner
picks one. A single text ("What was the total revenue?") is an extract_text step, and what was
read is shown in the terminal. A request that is a question (ending in "?", or starting with
"qual", "quanto", "what", "how many"...) is not done until some step has read the answer: if the
model stops before that, it is told to read it, and to open the page or tab that has it first.
python -m anchor.agent --profile ollama-small --url eval/fixtures/report_en.html "Export the sales by region table"