Osy#betaRun it on Osyrin: osyrin.com

Reference / Agent

Correct this, and an agent's Instructions page — the screens people teach an agent on (Agents.Teaching kit)

use Osysharp.Agents.Teaching; · WorkTeaching(task) · CorrectThis(task, step:, proposal:, label:, agent:, changed:, quiet:) · AgentInstructions(agent) · WorkTeachingOf(task) · InstructionBoardOf(agent) · SendCorrection(task, new CorrectionForm { … })

Osysharp.Agents.Teaching draws the two places people teach an agent. WorkTeaching(task) goes on the page of one piece of work: what it handed back, what it was told when it ran, each step of its record, and "Correct this" on each — what was wrong, what it should have been, why, and an instruction proposed from it in the same breath. AgentInstructions(agent) is an agent's Instructions page: what is waiting to be read, what is active and since when, who decided, what each was drawn from, how much work was sent it and how often it was still corrected, and the history of every set — with Activate, Edit, Reject, Retire and Roll back for those who teach.

preview1 example compiled by CIagentskitui

Summary#

use Osysharp.Agents.Teaching;

[Route("/work/{task}")] [Authorize(UsesAgents)]
component WorkPage(Guid task) { render { WorkTeaching(task); } }                    // correct a piece of work

[Route("/agents/tagger")] [Authorize(UsesAgents)]
component TaggerPage() { render { AgentInstructions(Agents.Of<Tagger>().Name); } }  // read, activate, retire, roll back

Signature#

component WorkTeaching(Guid task, bool beside = false)   // beside: only what teaching adds, under a page that shows the work
component CorrectThis(Guid task, int step = 0, Guid? proposal = null, string label = "Correct this",
                      string agent = "the agent", Action? changed = null, bool quiet = false)
component AgentInstructions(string agent)
component CorrectionLine(CorrectionCard c)

WorkTeachingOf(Guid task) → WorkTeachingView?       // null: not whoever-is-looking's to read
InstructionBoardOf(string agent) → InstructionBoard
SendCorrection(Guid task, CorrectionForm form) → CorrectionSent
class CorrectionForm { string Wrong, Right, Because; CorrectionSeverity Severity; int Step; Guid? Proposal;
                       bool Propose; string Guidance; bool OnlyForMe; }

Description#

What goes on a piece of work's page?#

WorkTeaching(task) draws, for whoever may read that work: what it is about and how it ended; what it handed back, with Correct this under it; what it was told — the sentence InstructionsOf says, the instructions it was sent, and those made active since that it was not; the corrections made so far, each with who wrote it and how much it mattered; and its steps, each with its own button once they are shown.

On a page that already shows the work — the inspector (The inspector — one piece of an agent's work, readable by a person who was not there (Agents.Inspector kit)) — WorkTeaching(task, beside: true) draws only what teaching adds: Correct this, the corrections made so far, and each step's own button.

Correct this opens in place: What was wrong?, What should it have been?, Why? — nothing is sent until all three say something — How much did it matter?, and Propose an instruction from this, which is on unless the person turns it off: From now on is what the agent would be told (left empty, what it should have been is used), for all that skill's work or only for the work it does for me. Sending says what happened in a sentence, and that the agent does nothing differently until somebody who teaches the agents makes the instruction active.

CorrectThis(task, step: n, label: "Correct step " + n) is the button alone, for a run page of your own; give each its own label so that they can be told apart, and quiet: true in a row of them.

What is on the Instructions page?#

AgentInstructions(agent), top to bottom:

  • Where it stands — the set the agent is on, and how many things it is told beyond what its developers wrote.
  • Waiting to be read — each proposed instruction: its words, its reason, what work it is for, who proposed it and from how many corrections (shown on request), with Activate, Edit and Reject. Shown only when something waits.
  • Active — the same, with who made it active and when, and whether it helped as counts; Retire asks why.
  • Retired and rejected — folded away; a retired one can be made active again.
  • History — every set, newest first: who changed what, when and why. Roll back to set N on each earlier one says what will happen and asks why.

Somebody who gives the agent work and does not teach it sees what it is told for their own work, what they proposed themselves, and no buttons. What a press is refused — a fourth instruction where three are the bound — is said on the row, in the kit's own words.

What do the screens decide?#

Nothing. Each press calls Osysharp.Agents' own function for it, which says who may; the screens offer a control only to somebody it will work for.

How is it tested?#

As a person: Ui.Click("Correct this"), fill the three questions by their labels, Ui.Click("Send correction"); on the page Ui.Click("Activate"), Ui.Click("Retire") then fill "Why is it retired?", Ui.Click("Roll back to set 1") then fill "Why is it put back?". Regions are named for within: — "Result", "What it was told", "Corrections", "Step 6", "Waiting to be read", "Active", "History", "Set 2". An agent's own run goes in a runas block with a scripted model.

Examples#

app Nursery {
  use Osysharp.Agents;
  use Osysharp.Agents.Teaching;
  use Osysharp.Llm;
  use Osysharp.Identity;
  use Osysharp.Observability;
  use Osysharp.Workflow;
  use Osysharp.Ui;
  model "model/**/*.osy";
}

using Osysharp.Agents;
using Osysharp.Agents.Teaching;
using Osysharp.Identity;
using Osysharp.Llm;

app.Llm = new LlmSetup {
  Models = [ new LlmModel { Name = "Everyday", Client = new ScriptedModel { Name = "Everyday" }, Model = "scripted-everyday",
                            Price = new LlmPrice { Input = 1, Output = 5 }, MaxOutputTokens = 1000 } ],
  Default = "Everyday",
};
app.Agents = new AgentsSetup { Agents = [new Tagger()] };

[Role] enum NurseryRole { Authenticator, Grower, Head, Tags }
partial entity RoleGrant { security { allow read when IsAuthenticated; } }
policy IsGrower => RoleGrant.Any(g => g.Member == user && g.Role == NurseryRole.Grower);
policy IsHead   => RoleGrant.Any(g => g.Member == user && g.Role == NurseryRole.Head);

policy UsesAgents       => IsGrower || IsHead;
policy SupervisesAgents => IsHead;
policy TeachesAgents    => IsHead;

entity Person : Principal {
  security { allow read when IsAuthenticated || IsAuthenticator; allow create when IsAuthenticator; }
}

public class Tag { public string Words = ""; }
public class WriteTag : Skill<string, Tag> { public override string Description => "Write the tag for one plant."; }

[Actor(Roles = [NurseryRole.Tags])]
public class Tagger : Agent {
  public static Person Principal => new Person { Email = "[email protected]", DisplayName = "Tagger" };
  public override string Purpose => "You write the tags that hang on the plants of a small nursery.";
  public override List<SkillBase> Skills => [new WriteTag()];
}

/// One piece of the tagger's work: what it handed back, what it was told, and "Correct this".
[Route("/work/{task}")] [Authorize(UsesAgents)] [Render(CSR)] [Title("The tagger's work")]
component WorkPage(Guid task) {
  render { Stack(p: 5, maxW: "860px") { WorkTeaching(task); } }
}

/// What the tagger is told: proposed, active, retired, and the history of every set.
[Route("/")] [Authorize(UsesAgents)] [Render(CSR)] [Title("Tagger")]
component TaggerPage() {
  render {
    Stack(gap: 5, p: 5, maxW: "860px") {
      PageHead("Tagger", subtitle: "Writes the tags that hang on the plants.");
      AgentInstructions("Tagger");
    }
  }
}

See also#

Related

Correcting an agent, and what it is told from then on — corrections, instructions, instruction sets and rollback (Agents kit)

An agent gets better through people. Somebody who sees a piece of its work corrects it — what was wrong, what right…

What an agent does alone, what it proposes, what it never does — the gate and proposals (Agents kit)

An agent's class says what it may do alone, what it must propose to a person first, and what it never does — by what a…

An agent's proposals and questions in a person's inbox, and an inbox item in an agent's hands (Agents.HumanRequests kit)

With the Agents kit and the HumanRequests kit both in an app, this bridge is there: what an agent proposes is an…

The receipt and the record — what every piece of an agent's work leaves (Agents kit)

Every piece of work leaves one receipt, `AgentTask` — who asked, the account it ran as, what it cost against its limit…

Agents (a class with a job, its own account, a budget and a record)

An agent is a class of the `Osysharp.Agents` kit: a purpose, the skills it holds and what it may spend. A skill is a…