Skip to content

Commit 2a133e4

Browse files
authored
feat: Introduce core harness interfaces (Handler, Harness, Execution) (#16)
* feat: Introduce core harness interfaces (Handler, Harness, Execution) Add the core interfaces for the new execution harness package. This includes: - Handler: interface with OnMessage and OnComplete callbacks for streaming turn execution outputs. - Harness: interface to start interactive execution sessions. - Execution: interface for managing conversational turns, message queue, IDs, and cleanup. TAG=agy CONV=c1af32c9-35e7-4583-bbd2-3be946e45699 * refactor: Make Queue parameter variadic for multi-message support Update the Queue method signature on the Execution interface to accept a variadic parameter of messages. This allows callers to queue a single message or multiple messages in one go. TAG=agy CONV=c1af32c9-35e7-4583-bbd2-3be946e45699
1 parent d75e2a9 commit 2a133e4

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

‎internal/harness/harness.go‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2026 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Package harness defines a common execution boundary and lifecycle hooks
16+
// for interacting with agents, planners, or external gRPC services.
17+
package harness
18+
19+
import (
20+
"context"
21+
22+
"github.com/google/ax/proto"
23+
)
24+
25+
// Handler defines the streaming event hook callbacks for an execution turn.
26+
type Handler interface {
27+
// OnMessage is invoked when the agent generates output content during its turn.
28+
OnMessage(ctx context.Context, execID string, msg *proto.Message) error
29+
30+
// OnComplete is invoked when the agent finishes its current execution turn.
31+
OnComplete(ctx context.Context, execID string) error
32+
}
33+
34+
// Harness represents a service capable of starting execution sessions.
35+
type Harness interface {
36+
// Start initializes a new Execution session for a conversation.
37+
Start(ctx context.Context, conversationID string) (Execution, error)
38+
}
39+
40+
// Execution represents an active interactive session with an agent or planner.
41+
type Execution interface {
42+
// Run executes the session and streams events to the provided Handler.
43+
// It blocks until the current turn completes or fails.
44+
Run(ctx context.Context, handler Handler) error
45+
46+
// Queue enqueues new input messages to be processed in the next turn.
47+
Queue(ctx context.Context, msg ...*proto.Message) error
48+
49+
// ID returns the unique execution session ID.
50+
ID() string
51+
52+
// Close cleanly releases all resources associated with the execution session.
53+
Close(ctx context.Context) error
54+
}

0 commit comments

Comments
 (0)