Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-17157-sidecar-knowledge-advise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- New opt-in `knowledge.sidecar_advise` (default `false`, also a switch at the top of Settings, Knowledge, applies without a restart) gives a sidecar-mode runtime the mid-task knowledge advisor through a new `POST /v1/knowledge/advise` route on the runtime-callback endpoint, which until now ran with no adviser at all. The route is served only behind the same bearer token as the other `/v1/*` callbacks and only while the knob, `knowledge.enabled` and `knowledge.advisor` are on; off, it answers `404 not_configured`, the hive does not advertise the `knowledge_advise` capability, and a sidecar runtime behaves exactly as before. The hive runs the adviser chain it runs in-process (phase 1, with the `advisor_llm` ranking pass, its budgets and the hive-wide pacer when configured), so no inference credential or model setting reaches the runtime and the model's reason is never typed. The runtime sends the scope and a pane tail redacted with `RedactPaneTokens` (the hive redacts again); the hive refuses with 403 an agent the calling runtime does not own or a kick that is not the agent's current one, with 429 a second call in flight for an agent or a third evaluation of one scope in a kick, with 400 a pane tail over `pane_lines`, and with 413 a body over 64 KiB. Any failure is no advice, with one warning per kick ([#17157](https://github.com/hivecommons/hive/issues/17157), part of [#17054](https://github.com/hivecommons/hive/issues/17054)).
24 changes: 22 additions & 2 deletions dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -19341,7 +19341,7 @@
"Knowledge"
],
"summary": "Knowledge pipeline settings",
"description": "Returns the scalar knowledge.bead_synthesizer, knowledge.curator, knowledge.code_maps and knowledge.primer settings, plus the read-only engine, vault paths and primer merge strategy. Requires owner role.",
"description": "Returns the scalar knowledge.bead_synthesizer, knowledge.curator, knowledge.code_maps and knowledge.primer settings and knowledge.sidecar_advise, plus the read-only engine, advisor flag, vault paths and primer merge strategy. Requires owner role.",
"responses": {
"200": {
"description": "Knowledge pipeline settings",
Expand All @@ -19354,6 +19354,14 @@
"type": "string",
"description": "Read-only: knowledge.engine"
},
"sidecar_advise": {
"type": "boolean",
"description": "knowledge.sidecar_advise: serve the mid-task knowledge advisor to a sidecar-mode runtime (default false)"
},
"advisor": {
"type": "boolean",
"description": "Read-only: knowledge.advisor, which sidecar_advise needs"
},
"bead_synthesizer": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -19506,14 +19514,18 @@
"Knowledge"
],
"summary": "Update knowledge pipeline settings",
"description": "Updates the scalar bead synthesizer, curator, code map and primer settings. Fields are pointer-typed; absent fields are left unchanged and 0 or empty restores the default. Validated with config.ValidateKnowledgePipeline before anything is applied, then persisted and audited as config_knowledge_pipeline. bead_synthesizer.enabled starts or stops the synthesizer at once; every other field applies after a restart. Requires owner role.",
"description": "Updates the scalar bead synthesizer, curator, code map and primer settings and knowledge.sidecar_advise. Fields are pointer-typed; absent fields are left unchanged and 0 or empty restores the default. Validated with config.ValidateKnowledgePipeline before anything is applied, then persisted and audited as config_knowledge_pipeline. bead_synthesizer.enabled and sidecar_advise apply at once; every other field applies after a restart. Requires owner role.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"sidecar_advise": {
"type": "boolean",
"description": "knowledge.sidecar_advise: serve the mid-task knowledge advisor to a sidecar-mode runtime (default false). Applies without a restart."
},
"bead_synthesizer": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -19640,6 +19652,14 @@
"type": "string",
"description": "Read-only: knowledge.engine"
},
"sidecar_advise": {
"type": "boolean",
"description": "knowledge.sidecar_advise: serve the mid-task knowledge advisor to a sidecar-mode runtime (default false)"
},
"advisor": {
"type": "boolean",
"description": "Read-only: knowledge.advisor, which sidecar_advise needs"
},
"bead_synthesizer": {
"type": "object",
"properties": {
Expand Down
33 changes: 27 additions & 6 deletions src/cmd/hive/agent_runtime_sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/hivecommons/hive/crux/effects"
"github.com/hivecommons/hive/crux/pushbroker"

"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/cruxhost"
"github.com/hivecommons/hive/pkg/fleetreport"
"github.com/hivecommons/hive/pkg/ioscan"
Expand Down Expand Up @@ -76,6 +77,11 @@ type sidecarHost struct {
mint crux.AgentMintIssuer
bobKey func() string
bobKeySource func() string
// knowledge is the mid-task adviser chain boot installed
// (hivecommons/hive#17157). It is held, not served: POST
// /v1/knowledge/advise answers from it only while
// knowledge.sidecar_advise is on, and the setter changes nothing else.
knowledge crux.KnowledgeAdviser
}

var _ hostedRuntime = (*sidecarHost)(nil)
Expand Down Expand Up @@ -331,12 +337,26 @@ func (h *sidecarHost) SetSandboxMutationBoundary(boundary effects.Boundary) {
// the runtime's own process); trajectory events do not depend on it.
func (h *sidecarHost) SetSpanStarter(crux.SpanStarter) { h.inProcessOnly("SetSpanStarter") }

// SetKnowledgeAdviser is in-process-only in phase 1 of hivecommons/hive#17052:
// the adviser searches the knowledge store that lives in the hive process.
// A sidecar runtime runs without the mid-task advisor until a callback route
// carries the scope → advice exchange.
func (h *sidecarHost) SetKnowledgeAdviser(crux.KnowledgeAdviser) {
h.inProcessOnly("SetKnowledgeAdviser")
// SetKnowledgeAdviser holds the adviser chain for the hive callback's
// POST /v1/knowledge/advise (hivecommons/hive#17157). The adviser searches the
// knowledge store that lives in the hive process, so the sidecar runtime sends
// the scope across and gets advice lines back; it never holds the chain. The
// route is off unless knowledge.sidecar_advise is set (default false), so with
// the knob off this changes nothing and a sidecar runtime runs without the
// mid-task advisor exactly as before.
func (h *sidecarHost) SetKnowledgeAdviser(adviser crux.KnowledgeAdviser) {
h.mu.Lock()
h.knowledge = adviser
h.mu.Unlock()
h.callbackCarried("SetKnowledgeAdviser")
}

// knowledgeAdviser is the chain SetKnowledgeAdviser installed, nil before
// boot has.
func (h *sidecarHost) knowledgeAdviser() crux.KnowledgeAdviser {
h.mu.Lock()
defer h.mu.Unlock()
return h.knowledge
}

// SetSandboxGitHubReadRelay is in-process-only (#18865): the relay holds the
Expand Down Expand Up @@ -506,6 +526,7 @@ func (b *boot) hiveCallbackCapabilities() *cruxhost.Capabilities {
deps.Mutation = sh
deps.Mint = sh
deps.Bob = sh.bobCredential
deps.Knowledge = newSidecarKnowledgeAdvise(func() *config.Config { return b.cfg }, sh.knowledgeAdviser, sh.GetStatusFast)
}
return cruxhost.New(deps)
}
Expand Down
Loading
Loading