Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(config): add summarizer settings to the context table

Steven Enamakelc07f4110f3c9
diff --git a/crates/openhuman-core/src/config/mod.rs b/crates/openhuman-core/src/config/mod.rs
index 8e90f351d1..4da322d633 100644
--- a/crates/openhuman-core/src/config/mod.rs
+++ b/crates/openhuman-core/src/config/mod.rs
@@ -48,7 +48,7 @@ pub use schema::{
BudgetPeriod, BudgetPolicy, BudgetScope, CapabilityProviderConfig,
CapabilityProviderTrustState, ChannelVoiceConfig, ChannelVoiceOverride, ChannelsConfig,
CompactionSettings, CompactionStrategy, ComposioConfig, ComposioDirectBaseUrls,
- ComposioHostCredential, ComputerConfig, Config, ContextConfig, CostConfig, CronConfig,
+ ComposioHostCredential, ComputerConfig, Config, ContextConfig, ContextSettings, CostConfig, CronConfig,
CurlConfig, DashboardConfig, DecisionModel, DiagramViewerConfig, DiscordConfig,
DockerRuntimeConfig, EmailConfig, EmbeddingRouteConfig, GitbooksConfig, HttpHeader,
HttpRequestConfig, IMessageConfig, IntegrationToggle, IntegrationsConfig, LarkConfig,
diff --git a/crates/openhuman-core/src/config/schema/context.rs b/crates/openhuman-core/src/config/schema/context.rs
index 731b54034d..f2a893567c 100644
--- a/crates/openhuman-core/src/config/schema/context.rs
+++ b/crates/openhuman-core/src/config/schema/context.rs
@@ -1,10 +1,72 @@
-//! TinyAgents-owned context settings re-exported through OpenHuman's config API.
+//! The `[context]` table: TinyAgents-owned context settings, re-exported
+//! through OpenHuman's config API, plus the summarizer settings OpenHuman adds
+//! beside them.
//!
//! OpenHuman keeps its product-specific environment overlays in
//! [`super::load`], while the shared settings, defaults, parsing, and
-//! serialization contract live with TinyAgents.
+//! serialization contract live with TinyAgents. [`ContextSettings`] flattens
+//! TinyAgents' [`ContextConfig`] and adds OpenHuman's own keys to the same
+//! table, so `config.context.<harness field>` keeps reading through `Deref`.
+
+use serde::{Deserialize, Serialize};
pub use tinyagents_harness::config::{CompactionSettings, CompactionStrategy, ContextConfig};
+pub use tinyagents_harness::summarization::ToolRendering;
+
+/// The whole `[context]` table: TinyAgents' [`ContextConfig`] and the
+/// compaction summarizer's OpenHuman-side settings.
+#[derive(Debug, Clone, Default, Serialize, Deserialize)]
+pub struct ContextSettings {
+ /// TinyAgents' context settings, flattened into the same table.
+ #[serde(flatten)]
+ pub harness: ContextConfig,
+ /// How the compaction summarizer sees tool activity: `full` (every call
+ /// and result) or `markers` (one `[used <tool>: …]` line per call, no
+ /// results), for small summarization models. Env:
+ /// `OPENHUMAN_CONTEXT_SUMMARIZER_TOOL_RENDERING`.
+ #[serde(default)]
+ pub summarizer_tool_rendering: ToolRendering,
+ /// Output cap for each summary, sent as the request's `max_tokens`. Unset
+ /// leaves the provider default. Env:
+ /// `OPENHUMAN_CONTEXT_SUMMARIZER_MAX_OUTPUT_TOKENS` (`0` clears it).
+ #[serde(default)]
+ pub summarizer_max_output_tokens: Option<u32>,
+}
+
+impl ContextSettings {
+ /// The summarizer settings a compaction applies.
+ pub fn summarizer_settings(&self) -> SummarizerSettings {
+ SummarizerSettings {
+ tool_rendering: self.summarizer_tool_rendering,
+ max_output_tokens: self.summarizer_max_output_tokens,
+ }
+ }
+}
+
+impl std::ops::Deref for ContextSettings {
+ type Target = ContextConfig;
+
+ fn deref(&self) -> &ContextConfig {
+ &self.harness
+ }
+}
+
+impl std::ops::DerefMut for ContextSettings {
+ fn deref_mut(&mut self) -> &mut ContextConfig {
+ &mut self.harness
+ }
+}
+
+/// How the free-form compaction summarizer renders its input and caps its
+/// output (`[context] summarizer_tool_rendering` /
+/// `summarizer_max_output_tokens`).
+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
+pub struct SummarizerSettings {
+ /// How tool calls and results reach the summarizer.
+ pub tool_rendering: ToolRendering,
+ /// The summary's `max_tokens`; `None` leaves the provider default.
+ pub max_output_tokens: Option<u32>,
+}
/// JSON-schema view of TinyAgents' serialized context settings.
///
@@ -26,6 +88,12 @@ pub(crate) struct ContextConfigSchema {
/// or blank, compaction uses the turn's model. Env:
/// `OPENHUMAN_CONTEXT_SUMMARIZER_MODEL`.
summarizer_model: Option<String>,
+ /// How the summarizer sees tool activity: `full` or `markers`. Env:
+ /// `OPENHUMAN_CONTEXT_SUMMARIZER_TOOL_RENDERING`.
+ summarizer_tool_rendering: ToolRenderingSchema,
+ /// The summary's `max_tokens`; unset leaves the provider default. Env:
+ /// `OPENHUMAN_CONTEXT_SUMMARIZER_MAX_OUTPUT_TOKENS`.
+ summarizer_max_output_tokens: Option<u32>,
prefer_markdown_tool_output: bool,
compaction_enabled: bool,
compaction_trigger_tokens: Option<u64>,
@@ -38,3 +106,10 @@ enum CompactionStrategySchema {
TaskState,
Summary,
}
+
+#[derive(schemars::JsonSchema)]
+#[schemars(rename_all = "snake_case")]
+enum ToolRenderingSchema {
+ Full,
+ Markers,
+}
diff --git a/crates/openhuman-core/src/config/schema/mod.rs b/crates/openhuman-core/src/config/schema/mod.rs
index 2d494be093..8e5a9a51e2 100644
--- a/crates/openhuman-core/src/config/schema/mod.rs
+++ b/crates/openhuman-core/src/config/schema/mod.rs
@@ -124,7 +124,10 @@ pub use channels::{
StreamMode, TelegramConfig, WhatsAppConfig, YuanbaoConfig,
};
pub(crate) use cli_overrides::set_cli_inference_overrides;
-pub use context::{CompactionSettings, CompactionStrategy, ContextConfig};
+pub use context::{
+ CompactionSettings, CompactionStrategy, ContextConfig, ContextSettings, SummarizerSettings,
+ ToolRendering,
+};
pub use cron::CronConfig;
pub use dashboard::{DashboardConfig, DiagramViewerConfig, EventStreamConfig, ModelHealthConfig};
pub use identity_cost::{
diff --git a/crates/openhuman-core/src/config/schema/types/config.rs b/crates/openhuman-core/src/config/schema/types/config.rs
index 9b85c55c5f..57455a75ef 100644
--- a/crates/openhuman-core/src/config/schema/types/config.rs
+++ b/crates/openhuman-core/src/config/schema/types/config.rs
@@ -290,7 +290,7 @@ pub struct Config {
/// the agent context middleware configuration.
#[serde(default)]
#[schemars(with = "super::super::context::ContextConfigSchema")]
- pub context: ContextConfig,
+ pub context: ContextSettings,
#[serde(default)]
pub model_routes: Vec<ModelRouteConfig>,
diff --git a/crates/openhuman-core/src/config/schema/types/defaults.rs b/crates/openhuman-core/src/config/schema/types/defaults.rs
index 4e4cc686e6..e2e77729a9 100644
--- a/crates/openhuman-core/src/config/schema/types/defaults.rs
+++ b/crates/openhuman-core/src/config/schema/types/defaults.rs
@@ -66,7 +66,7 @@ impl Default for Config {
agent: AgentConfig::default(),
orchestrator: OrchestratorModelConfig::default(),
teams: HashMap::new(),
- context: ContextConfig::default(),
+ context: ContextSettings::default(),
model_routes: Vec::new(),
embedding_routes: Vec::new(),
cron: CronConfig::default(),