antigravityinteractions

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultAgent is the Interactions API agent used when the harness is
	// registered without an explicit agent override.
	DefaultAgent = "antigravity-preview-05-2026"
)

Variables

This section is empty.

Functions

func APIVersion

func APIVersion() string

APIVersion returns the Interactions API version this harness targets.

func DefaultStateDir

func DefaultStateDir() (string, error)

DefaultStateDir returns the default resume-cursor directory, <AXAssetsDir>/antigravityinteractions/cursors, used when a caller does not set StateDir explicitly. Locally that is ~/.ax/...; on a substrate actor AX_DURABLE_DIR points AXAssetsDir at a durable volume (e.g. /durable/.ax), kept outside the agent's working directory so the agent does not see or modify it. New still requires a non-empty StateDir; callers apply this default.

func Endpoint

func Endpoint() string

Endpoint returns the Interactions API base endpoint this harness targets (e.g. the prod or autopush host). Exposed so callers/tools can log which backend is in use, since the endpoint is a compile-time constant.

func JoinSystemInstruction

func JoinSystemInstruction(base, pointer string) string

JoinSystemInstruction combines a user-configured system instruction with an optional skills pointer (from SkillsSystemInstruction), dropping empties.

func Serve

func Serve(ctx context.Context, cfg AntigravityInteractionsConfig, host string, port, readyzPort int) error

Serve builds the Antigravity Interactions harness from cfg and serves the HarnessService (plus gRPC health) on host:port, and an HTTP /readyz endpoint on readyzPort that reflects this server's own serving state. It blocks until ctx is cancelled or a termination signal (SIGINT/SIGTERM) is received, then shuts down gracefully.

func SkillsSystemInstruction

func SkillsSystemInstruction(res geminienterprise.Result) string

SkillsSystemInstruction builds a system-instruction pointer telling the agent where its materialized skills live and lists them.

This is discovery logic specific to the Antigravity Interactions harness: it has no SKILLS_DIR concept, so it must be told where to find skills via its system instruction (its built-in file tools then read that directory). Harnesses that auto-discover a skills directory (e.g. the Antigravity SDK harness via SKILLS_DIR) do not use this.

func WorkspaceSystemInstruction

func WorkspaceSystemInstruction(workDir string) string

WorkspaceSystemInstruction builds a system-instruction snippet that orients the agent about its working directory.

This complements the executor making WorkDir authoritative (see AntigravityInteractionsConfig.WorkDir): the executor guarantees commands run in the right place, while this tells the agent so it emits sensible paths (relative to the workspace, not the process root "/"). Returns "" when workDir is empty.

Types

type AntigravityInteractionsConfig

type AntigravityInteractionsConfig struct {

	// Agent is the Interactions API agent name to run. Required: the API rejects a
	// request with no agent.
	Agent string

	// StateDir is the directory where each conversation's resume cursor is
	// persisted, so a conversation can resume after a restart. Required: New
	// returns an error if it is empty.
	//
	// Correctness relies on a single writer per conversation: writes are
	// last-write-wins with no compare-and-swap. This is an expectation the caller
	// must satisfy (e.g. by routing a conversation id to one worker, or resuming
	// a worker from that conversation's snapshot) -- it is not currently enforced
	// by the controller.
	StateDir string

	// WorkDir is the working directory the agent operates in. When set, it is the
	// authoritative base for built-in env tools: run_command executes there (and
	// resolves a relative Cwd against it). This makes tool execution independent
	// of the process's ambient cwd. Empty means "use the process cwd" (the
	// previous behavior). Defaults from AX_HARNESS_WORKDIR.
	WorkDir string

	// SystemInstruction, if set, is sent as the interaction's system_instruction
	// (a free-form system prompt prepended to the agent's own instructions). It
	// is sent on every turn of the interaction loop so it persists across them.
	SystemInstruction string
	// MaxTurns caps the number of interaction turns the harness will drive within
	// a single Run before giving up. Defaults to 100.
	MaxTurns int
	// Debug, if true, logs concise per-conversation tool activity to stderr: a
	// line for each function call (FC) the agent yields and each function result
	// (FR) the harness produces. Useful for observing the FC/FR exchange that is
	// otherwise internal to the harness.
	Debug bool
	// ThirdPartyExecutor executes third-party (non-built-in) function tool calls
	// and declares them to the agent. It is the seam for the controller to inject
	// the caller's tool implementations. If nil, the harness advertises no
	// third-party tools and any non-built-in call the agent attempts yields an
	// error result.
	ThirdPartyExecutor ThirdPartyExecutor
	// TokenSource overrides how the bearer token is obtained. If nil, the harness
	// builds an auto-refreshing source from Application Default Credentials.
	TokenSource oauth2.TokenSource
}

AntigravityInteractionsConfig configures an AntigravityInteractionsHarness. Use New, which fills sensible defaults.

Cloud project and location come from the standard GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables.

type AntigravityInteractionsHarness

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

AntigravityInteractionsHarness implements Harness by talking to the public Vertex GenAI Interactions API.

func New

New creates a harness from the given config, filling in defaults for unset fields. It returns an error if cfg.StateDir is empty or the cursor store cannot be created: resume-cursor persistence is required, so a usable state directory must be provided.

func (*AntigravityInteractionsHarness) Start

func (h *AntigravityInteractionsHarness) Start(ctx context.Context, conversationID string, harnessConfig []byte) (harness.Execution, error)

Start implements Harness.Start. It loads any previously persisted resume cursor for conversationID so the returned Execution resumes the existing interaction chain instead of starting a new one.

type FunctionTool

type FunctionTool struct {
	Type   string `json:"type"` // "function"
	Name   string `json:"name"`
	Desc   string `json:"description,omitempty"`
	Params any    `json:"parameters,omitempty"`
}

FunctionTool is a client-declared function tool declaration. It is the element type a ThirdPartyExecutor returns from Declarations.

type ThirdPartyExecutor

type ThirdPartyExecutor interface {
	// Declarations returns the tool declarations advertised to the agent.
	Declarations() []FunctionTool
	// Execute runs the named tool with the given arguments and returns the result
	// value to send back to the agent (wrapped into the function_result step).
	Execute(ctx context.Context, name string, args map[string]any) any
}

ThirdPartyExecutor declares and executes third-party (non-built-in) function tools. The harness owns when it is called; an implementation just needs to describe its tools and produce a result for a given call.

Jump to

Keyboard shortcuts

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