Documentation
¶
Overview ¶
Package platformfeedback is what agents report the platform could not do for them (#2820), delivered to whoever runs the platform.
The audit records that a call failed, not what the agent wanted. An agent knows at the moment it is blocked what it needed, and that knowledge was lost with the session; the only record of intent in three production deployments was a handful of tool-finding queries. A post here keeps it: what the agent was trying to do, what blocked it, the tool, a suggestion, and the calls involved by reference.
Every text field passes the content secret check (internal/secretscan) before anything is written, posts are bounded per session and per persona, a repeat of an open post is counted on it, and nothing is sent until an administrator turns the feature on and names the channels.
Index ¶
- Constants
- Variables
- func Register(mux *http.ServeMux, wrap func(http.Handler) http.Handler, svc *Service, ...)
- type Caller
- type ChannelSender
- type Delivery
- type Deps
- type Detail
- type Improvement
- type InvalidError
- type Item
- type ListFilter
- type ListResponse
- type PersonaPrompts
- type Post
- type PromptKinds
- type PromptsResponse
- type RefusedError
- type Report
- type ResendRequest
- type Result
- type Service
- func (s *Service) Get(ctx context.Context, id string) (Detail, error)
- func (s *Service) List(ctx context.Context, f ListFilter) (ListResponse, error)
- func (s *Service) MayPost(ctx context.Context, persona string) bool
- func (s *Service) Prompts(ctx context.Context, days int) (PromptsResponse, error)
- func (s *Service) Resend(ctx context.Context, id, channel string) error
- func (s *Service) SaveSettings(ctx context.Context, in Settings, author string) (settingsjson.Stored[Settings], error)
- func (s *Service) SetStatus(ctx context.Context, id string, ch StatusChange, by string) error
- func (s *Service) Settings(ctx context.Context) settingsjson.Stored[Settings]
- func (s *Service) Submit(ctx context.Context, c Caller, p Post) (Result, error)
- type Settings
- type SettingsView
- type Stats
- type StatusChange
Constants ¶
const ( // KindBlocked is a post about something the platform could not do: what // the agent was trying to do and what stopped it (#2820). KindBlocked = "blocked" // KindImprovement is a post about something the platform made harder than // it had to be: what the agent observed, the change it proposes, and what // that change would buy (#2885). KindImprovement = "improvement" )
The kinds of post.
const ( BenefitPossible = "possible" BenefitFewerSteps = "fewer_steps" BenefitFewerCalls = "fewer_calls" BenefitFewerTokens = "fewer_tokens" )
The benefit kinds an improvement may name, in the order the list ranks them: a task that becomes possible ranks above one that takes fewer steps, calls or tokens.
const ( DefaultSessionLimit = 5 DefaultPersonaDailyLimit = 50 )
Defaults for the limits.
const ( CodeOff = "platform_feedback_off" CodePersona = "platform_feedback_persona" CodeLimit = "platform_feedback_limit" CodeSecret = "platform_feedback_secret" CodeInvalid = "platform_feedback_invalid" // CodeShipped refuses a repeat of a post already shipped, naming the // release (#2885). CodeShipped = "platform_feedback_shipped" // CodeDeclined refuses a repeat of a post already declined, naming the // reason (#2885). CodeDeclined = "platform_feedback_declined" )
Codes a post is refused with.
const ( StatusOpen = "open" StatusPlanned = "planned" StatusDone = "done" StatusDeclined = "declined" )
Statuses a post moves through.
const DefaultEmbedTimeout = 5 * time.Second
DefaultEmbedTimeout is how long a post waits for its embedding (#2829). The embedding only folds a near-duplicate onto an open post, so a busy embedding service, as right after an upgrade re-embeds the platform's knowledge, costs a missed fold and never the report.
const SectionName = "platform_feedback"
SectionName is the platform_settings section the settings are kept in.
Variables ¶
var ErrNotFound = errors.New("platform feedback post not found")
ErrNotFound is a post that does not exist.
Functions ¶
Types ¶
type ChannelSender ¶
type ChannelSender interface {
NotifyChannel(ctx context.Context, s notification.ChannelSend) (notification.ChannelResult, error)
}
ChannelSender queues a document for one channel; notification.Enqueuer is one.
type Delivery ¶
type Delivery struct {
Channel string `json:"channel"`
Status string `json:"status"`
Attempts int `json:"attempts"`
LastError string `json:"last_error,omitempty"`
SentAt *time.Time `json:"sent_at,omitempty"`
}
Delivery is a post's send to one channel, as the notification queue holds it.
type Deps ¶
type Deps struct {
// DB holds the posts and the notification queue rows their sends wrote.
DB *sql.DB
// Section holds the settings; nil is "off".
Section *settingsjson.Section[Settings]
// Detector checks every text field for a credential before anything is
// written.
Detector secretscan.Detector
// Embed turns a post's words into a vector for folding a repeat; nil
// folds only an exact repeat.
Embed func(ctx context.Context, text string) ([]float32, error)
// EmbedTimeout bounds Embed; zero is DefaultEmbedTimeout. A post whose
// embedding does not come back in time is stored and sent unfolded, but
// for a repeat of its exact words (#2829).
EmbedTimeout time.Duration
// Channels resolves a channel name; Sender queues a send to it.
Channels notification.ChannelStore
Sender ChannelSender
// ServiceAccount reports a persona whose calls are machinery: it may not
// post when the settings name no personas.
ServiceAccount func(persona string) bool
// KnownPersona checks a persona a settings save names.
KnownPersona func(persona string) bool
// PortalURL is the portal's public address, for the link a send carries.
PortalURL string
// Now is the clock; nil is time.Now.
Now func() time.Time
}
Deps is what the service reads.
type Detail ¶
type Detail struct {
Item
Reports []Report `json:"reports"`
Deliveries []Delivery `json:"deliveries"`
}
Detail is one post with its reports and deliveries.
type Improvement ¶ added in v1.172.0
type Improvement struct {
// Observed is what was slow, repetitive or awkward, as what the agent did.
Observed string `json:"observed,omitempty"`
// Proposal is the tool, parameter, action, page or behavior that would
// remove it.
Proposal string `json:"proposal,omitempty"`
// Benefit is what changes: fewer calls or tokens, one step instead of a
// workaround, a task that becomes possible.
Benefit string `json:"benefit,omitempty"`
// BenefitKind is the benefit as one of the ranked kinds, optional.
BenefitKind string `json:"benefit_kind,omitempty"`
}
Improvement is what an improvement post carries.
type InvalidError ¶
type InvalidError struct{ Msg string }
InvalidError is a settings save refused for what it holds.
func (*InvalidError) Error ¶
func (e *InvalidError) Error() string
type Item ¶
type Item struct {
ID string `json:"id"`
Kind string `json:"kind"`
TryingTo string `json:"trying_to"`
BlockedBy string `json:"blocked_by"`
Tool string `json:"tool"`
Suggestion string `json:"suggestion"`
Improvement
Status string `json:"status"`
// StatusRelease is the release a post marked done shipped in, and
// StatusReason why a declined one was declined.
StatusRelease string `json:"status_release,omitempty"`
StatusReason string `json:"status_reason,omitempty"`
ReportCount int `json:"report_count"`
// Personas and Sessions are how many distinct personas and sessions
// reported the post (#2885): how widely it is wanted.
Personas int `json:"personas"`
Sessions int `json:"sessions"`
CreatedAt time.Time `json:"created_at"`
LastReportedAt time.Time `json:"last_reported_at"`
}
Item is one post as the list shows it.
type ListFilter ¶
type ListFilter struct {
// Kind is blocked or improvement; empty is both.
Kind string
Status string
Tool string
Query string
// Rank orders by how wanted a post is (reports, then distinct personas,
// then sessions, then the benefit it claims) instead of by its newest
// report (#2885).
Rank bool
Limit int
Offset int
}
ListFilter narrows the list.
type ListResponse ¶
type ListResponse struct {
Posts []Item `json:"posts"`
Total int `json:"total"`
Stats Stats `json:"stats"`
}
ListResponse is a page of posts and the page's counts.
type PersonaPrompts ¶ added in v1.172.0
type PersonaPrompts struct {
Persona string `json:"persona"`
Prompts PromptKinds `json:"prompts"`
Shown int `json:"shown"`
Posts int `json:"posts"`
}
PersonaPrompts is one persona's prompts to post platform feedback over a period, and the posts it made in that period.
type Post ¶
type Post struct {
// Kind is KindBlocked (the default) or KindImprovement.
Kind string `json:"kind,omitempty"`
TryingTo string `json:"trying_to"`
BlockedBy string `json:"blocked_by"`
Tool string `json:"tool,omitempty"`
Suggestion string `json:"suggestion,omitempty"`
Calls []string `json:"calls,omitempty"`
Improvement
}
Post is one report as an agent writes it: a block (what it was trying to do and what stopped it) or, since #2885, an improvement (what was slow or awkward, the change that would remove it, and what that would buy).
type PromptKinds ¶ added in v1.172.0
type PromptKinds struct {
Refusal int `json:"refusal"`
Missing int `json:"missing"`
Gate int `json:"gate"`
Pattern int `json:"pattern"`
}
PromptKinds is how many prompts of each kind a persona was shown.
type PromptsResponse ¶ added in v1.172.0
type PromptsResponse struct {
Days int `json:"days"`
Personas []PersonaPrompts `json:"personas"`
}
PromptsResponse is the prompts and posts of every persona that was shown a prompt or posted in the period, most prompted first.
type RefusedError ¶
RefusedError is a post refused, with the code a caller branches on. Its message never repeats a field's content.
func (*RefusedError) Error ¶
func (e *RefusedError) Error() string
type Report ¶
type Report struct {
Persona string `json:"persona"`
UserID string `json:"-"`
SessionID string `json:"-"`
Calls []string `json:"calls"`
ReportedAt time.Time `json:"reported_at"`
}
Report is one report of a post: who and in which session, and the calls it names.
type ResendRequest ¶
type ResendRequest struct {
Channel string `json:"channel" example:"ops-webhook"`
}
ResendRequest names the channel a post is sent to again.
type Result ¶
type Result struct {
ID string `json:"id"`
ReportCount int `json:"report_count"`
// Folded is true when the post repeated an open one and was counted on it
// rather than stored and sent again.
Folded bool `json:"folded"`
// Channels is how many channels the new post was queued for.
Channels int `json:"channels"`
Message string `json:"message"`
}
Result is what a post did.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is platform feedback.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, f ListFilter) (ListResponse, error)
List is the posts a filter selects, with the page's counts.
func (*Service) MayPost ¶ added in v1.172.0
MayPost reports whether a persona may post platform feedback now: the topic is on and the settings let the persona post. Prompts to post are given only when it does (#2885).
func (*Service) Prompts ¶ added in v1.172.0
Prompts counts, per persona, the tool results that told an agent to post platform feedback over the last days (7, 30 or 90), and the posts it made: whether the prompts lead anywhere (#2885).
func (*Service) Resend ¶
Resend queues a post again for one channel the settings name, as a delivery that failed is retried by hand.
func (*Service) SaveSettings ¶
func (s *Service) SaveSettings(ctx context.Context, in Settings, author string) (settingsjson.Stored[Settings], error)
SaveSettings validates and stores the settings.
type Settings ¶
type Settings struct {
// Enabled lets agents post. Off by default.
Enabled bool `json:"enabled"`
// Channels are the notification channels a new post is sent to.
Channels []string `json:"channels"`
// Personas may post; empty is every persona except service accounts.
Personas []string `json:"personas"`
// SessionLimit is the most posts one session may make.
SessionLimit int `json:"session_limit"`
// PersonaDailyLimit is the most posts one persona may make in a day.
PersonaDailyLimit int `json:"persona_daily_limit"`
}
Settings is how platform feedback is configured in Admin > Settings.
type SettingsView ¶
type SettingsView struct {
Settings
UpdatedBy string `json:"updated_by,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
SettingsView is the settings with who saved them.
type Stats ¶
type Stats struct {
Open int `json:"open"`
ImprovementsOpen int `json:"improvements_open"`
ReportsThisWeek int `json:"reports_this_week"`
RefusedThisWeek int `json:"refused_this_week"`
DeliveryFailures int `json:"delivery_failures"`
// PromptsThisWeek is how many tool results told an agent to post platform
// feedback this week (#2885).
PromptsThisWeek int `json:"prompts_this_week"`
}
Stats are the list page's counts.
type StatusChange ¶ added in v1.172.0
type StatusChange struct {
Status string `json:"status" example:"done"`
Release string `json:"release,omitempty" example:"v1.172.0"`
Reason string `json:"reason,omitempty" example:"Covered by trino_export's columns parameter"`
}
StatusChange moves a post to a status. A post marked done (shipped) names the release it went out in, and a declined one the reason; an agent that posts it again is told either (#2885).