refactor: fix flaky test and remove dead code in recent commits

Fixes issues in the last 11 commits:

1. pending_research.rs: Fix flaky test_generate_id_uniqueness
   - Replaced random u16 suffix with atomic counter for guaranteed uniqueness
   - The timestamp+random approach could collide when generating IDs rapidly
   - Now uses static AtomicU32 counter that increments monotonically

2. embedded/adapters/glm.rs: Remove unused in_code_fence field
   - Field was written but never read (dead code)
   - Removed from struct definition, constructor, and reset()

3. embedded/adapters/glm.rs: Fix orphaned tests
   - Two tests (test_strip_code_fences, test_code_fenced_tool_call) were
     outside the #[cfg(test)] mod tests block
   - Moved closing brace to include them in the test module

All 446 library tests pass.

Agent: fowler
This commit is contained in:
Dhanji R. Prasanna
2026-01-30 14:28:43 +11:00
parent 6bb07ce4f5
commit 3003bdebaa
2 changed files with 6 additions and 7 deletions

View File

@@ -61,8 +61,6 @@ pub struct GlmToolAdapter {
buffer: String,
/// Buffer for current line (to detect code fences)
line_buffer: String,
/// Whether we're currently inside a code fence
in_code_fence: bool,
/// Current parse state
state: ParseState,
/// JSON parsing state (when in InToolJson)
@@ -78,7 +76,6 @@ impl GlmToolAdapter {
Self {
buffer: String::new(),
line_buffer: String::new(),
in_code_fence: false,
state: ParseState::Prose,
json_state: JsonState::Normal,
json_depth: 0,
@@ -457,7 +454,6 @@ impl ToolFormatAdapter for GlmToolAdapter {
fn reset(&mut self) {
self.buffer.clear();
self.line_buffer.clear();
self.in_code_fence = false;
self.state = ParseState::Prose;
self.json_state = JsonState::Normal;
self.json_depth = 0;
@@ -696,7 +692,6 @@ Second:<|assistant|>read_file
assert_eq!(output.emit, "Normal text");
assert!(!output.has_tool_call);
}
}
#[test]
fn test_strip_code_fences() {
@@ -731,3 +726,4 @@ Second:<|assistant|>read_file
assert!(!full.contains("```"));
assert!(full.contains("{\"tool\": \"shell\""));
}
}