pub struct GeminiConnection { /* private fields */ }Expand description
A live Gemini session that implements Connection.
Implementations§
Source§impl GeminiConnection
impl GeminiConnection
Sourcepub fn history_bytes(&self) -> Result<Vec<u8>>
pub fn history_bytes(&self) -> Result<Vec<u8>>
Snapshot the current conversation history as opaque bytes.
Round-trips through set_history_bytes; the on-disk format is
not part of the public API and may change between minor versions.
Sourcepub fn set_thinking_override(&self, level: Option<ThinkingLevel>)
pub fn set_thinking_override(&self, level: Option<ThinkingLevel>)
Set (or clear, with None) the PER-TURN thinking override — the
difficulty-router seam. Applies to the NEXT turn’s model call only; the
session’s configured thinking is restored after. None (the default)
means “use the configured level”. Cheap to call between turns; does NOT
rebuild the connection or touch history.
Sourcepub fn set_model_override(&self, model: Option<String>)
pub fn set_model_override(&self, model: Option<String>)
Set (or clear, with None) the PER-TURN model override — the
difficulty-router model seam (#7), parallel to
set_thinking_override. Applies to the
NEXT turn only; the configured model is restored after. None (the
default) is a no-op. The caller MUST pass a same-backend id no more
capable than the session’s selected model — switching backends is unsafe
(different wire format + history shape) and must never be done here.
Cheap: does NOT rebuild the connection or touch history; the proxy routes
every model to the same endpoint, so only the request’s model field
changes.
Sourcepub fn set_history_bytes(&self, bytes: &[u8]) -> Result<()>
pub fn set_history_bytes(&self, bytes: &[u8]) -> Result<()>
Replace the entire conversation history with one previously
returned by history_bytes. Use this on connection start to
resume a saved session; calling it mid-turn is undefined.
Sourcepub async fn compact(&self) -> bool
pub async fn compact(&self) -> bool
Manually trigger context compaction. Summarises older history
entries and replaces them with a single synthetic turn, freeing
context-window budget. Returns true if compaction changed the
history, false if it was too short or the summarisation was a
no-op. Never errors — failures are logged and silently skipped.
Sourcepub fn clear_history(&self)
pub fn clear_history(&self)
Wipe the entire conversation history, returning the connection to a
fresh, empty context. Synchronous (no network). Backs
crate::Agent::clear_history — the in-tab clear_context tool.
Resets only the history and the per-turn bookkeeping that could
otherwise re-trigger compaction on the now-tiny history; the live
step broadcast and conversation_id are left untouched.
Sourcepub fn transcript(&self) -> Vec<TranscriptEntry>
pub fn transcript(&self) -> Vec<TranscriptEntry>
Project the wire history into a flat sequence of user/assistant
turns suitable for repainting a UI. Tool-call activity
(FunctionCall / FunctionResponse) is surfaced as TranscriptToolCalls
(matched by name), so a restored session shows what the agent DID, not
just what it said.
Trait Implementations§
Source§impl Connection for GeminiConnection
impl Connection for GeminiConnection
Source§fn is_idle(&self) -> bool
fn is_idle(&self) -> bool
AtomicBool so callers may poll without contention.Source§fn conversation_id(&self) -> &str
fn conversation_id(&self) -> &str
Source§fn send<'life0, 'async_trait>(
&'life0 self,
content: Content,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
content: Content,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Connection::subscribe_steps.Source§fn send_trigger<'life0, 'async_trait>(
&'life0 self,
content: String,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_trigger<'life0, 'async_trait>(
&'life0 self,
content: String,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
send,
this does not switch the turn boundary.