goalkeeper

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package goalkeeper builds an ADK workflow for goal-directed work with validation.

A Goalkeeper workflow runs two caller-provided agents in order:

  1. worker
  2. validator

The agents run inside one ADK LoopAgent invocation and share the same ADK session. The loop stops when the validator's final visible model response starts exactly with "verdict: pass", or when the configured maximum iteration count is reached. Validator responses that start with "verdict: fail", or responses without a recognized verdict, do not stop the loop.

Thought parts are ignored when checking the validator verdict. Only visible final response text is considered.

Construct workflows with NewOptions and New:

workflow, err := goalkeeper.New(goalkeeper.NewOptions(worker, validator))
workflow, err := goalkeeper.New(goalkeeper.NewOptions(
	worker,
	validator,
	goalkeeper.WithMaxIterations(3),
))

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts Options) (agent.Agent, error)

New creates a Goalkeeper workflow agent from options.

Example
package main

import (
	"fmt"
	"iter"

	"github.com/normahq/norma/pkg/goalkeeper"
	"google.golang.org/adk/agent"
	"google.golang.org/adk/session"
)

func main() {
	worker, _ := agent.New(agent.Config{
		Name:        "worker",
		Description: "does the requested work",
		Run: func(agent.InvocationContext) iter.Seq2[*session.Event, error] {
			return func(func(*session.Event, error) bool) {}
		},
	})
	validator, _ := agent.New(agent.Config{
		Name:        "validator",
		Description: "checks whether the goal is complete",
		Run: func(agent.InvocationContext) iter.Seq2[*session.Event, error] {
			return func(func(*session.Event, error) bool) {}
		},
	})

	workflow, _ := goalkeeper.New(goalkeeper.NewOptions(
		worker,
		validator,
		goalkeeper.WithMaxIterations(3),
	))

	fmt.Println(workflow.Name())
}
Output:
Goalkeeper

Types

type OptOptionsSetter

type OptOptionsSetter func(o *Options)

func WithMaxIterations

func WithMaxIterations(opt uint) OptOptionsSetter

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options configures the Goalkeeper workflow agent.

func NewOptions

func NewOptions(
	worker agent.Agent,
	validator agent.Agent,
	options ...OptOptionsSetter,
) Options

func (*Options) Validate

func (o *Options) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL