• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lucasliet / llm-telegram-bot / 21687984441
55%

Build:
DEFAULT BRANCH: main
Ran 04 Feb 2026 08:53PM UTC
Jobs 1
Files 43
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

04 Feb 2026 08:53PM UTC coverage: 59.131% (-2.3%) from 61.43%
21687984441

push

github

web-flow
feat: agent tool call loop (#22)

# Agent Loop Implementation - Resumo

## 📦 Estrutura Criada

```
src/service/openai/
├── agent/
│   ├── AgentLoopConfig.ts      # Configurações e tipos
│   ├── AgentLoopExecutor.ts    # Orquestrador do loop
│   └── index.ts                # Exports
├── stream/
│   ├── StreamProcessor.ts      # Interface base
│   ├── ChatCompletionsStream.ts    # Processador Chat API
│   ├── ResponsesAPIStream.ts       # Processador Responses API
│   └── index.ts                # Exports
└── OpenAIService.ts            # Serviço refatorado
```

## 🎯 Mudança Fundamental

### Antes (comportamento original)
```typescript
if (tool_calls.length > 0) {
  // Executa tools UMA vez
  // Retorna resposta
}
```

### Depois (comportamento agente)
```typescript
while (tool_calls.length > 0) {
  // Executa tools
  // Acumula resultados no contexto
  // Faz nova chamada ao modelo
  // Repete até o modelo retornar apenas mensagem de texto
}
```

## 🔧 Componentes Principais

### 1. AgentLoopConfig
- `maxIterations`: Limite de iterações (padrão: 10)
- `maxContextTokens`: Limite de tokens no contexto (padrão: 100000)
- `toolExecutionTimeout`: Timeout por tool (padrão: 30000ms)
- Callbacks opcionais para observabilidade

### 2. StreamProcessor (interface)
- `processStream()`: Processa stream e extrai tool calls
- `formatToolResultsForNextCall()`: Formata resultados para próxima chamada

### 3. ChatCompletionsStreamProcessor
- Implementa `StreamProcessor` para Chat Completions API
- Acumula tool calls que vêm em chunks
- Formata como `ChatCompletionMessageParam[]`

### 4. ResponsesAPIStreamProcessor
- Implementa `StreamProcessor` para Responses API
- Processa eventos SSE (Server-Sent Events)
- Formata como `ResponseInputItem[]`

### 5. AgentLoopExecutor
- Orquestra o loop recursivo
- Executa tools em paralelo
- Gerencia estado e proteções
- Mantém streaming ativo para o usuário

## ✅ Compatibilidade

### Com Subclasses
- `GithubCopilotService`
- `Perplexit... (continued)

113 of 269 branches covered (42.01%)

Branch coverage included in aggregate %.

584 of 1242 new or added lines in 17 files covered. (47.02%)

7 existing lines in 4 files now uncovered.

2228 of 3690 relevant lines covered (60.38%)

15.18 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
1
92.31
0.0% src/handlers/VertexHandler.ts
1
39.19
0.0% src/util/FileUtils.ts
3
55.52
0.0% src/service/TelegramService.ts
8
16.53
-1.01% src/service/openai/GithubCopilotService.ts
18
56.63
-3.25% src/prototype/ContextExtensionPrototype.ts
24
61.54
0.0% src/handlers/HandlerUtils.ts
44
57.44
12.76% src/service/openai/OpenAIService.ts
70
23.66
src/service/openai/stream/ChatCompletionsStream.ts
72
24.74
src/service/openai/stream/ResponsesAPIStream.ts
93
9.4
0.0% src/service/openai/VertexAiService.ts
126
66.35
0.15% src/service/ToolService.ts
198
28.62
src/service/openai/agent/AgentLoopExecutor.ts

Uncovered Existing Lines

Lines Coverage ∆ File
1
61.54
0.0% src/handlers/HandlerUtils.ts
1
57.44
12.76% src/service/openai/OpenAIService.ts
2
9.4
0.0% src/service/openai/VertexAiService.ts
3
56.63
-3.25% src/prototype/ContextExtensionPrototype.ts
Jobs
ID Job ID Ran Files Coverage
1 21687984441.1 04 Feb 2026 08:53PM UTC 43
59.13
GitHub Action Run
Source Files on build 21687984441
  • Tree
  • List 43
  • Changed 6
  • Source Changed 0
  • Coverage Changed 6
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • 81b99eb5 on github
  • Prev Build on main (#21686024958)
  • Next Build on main (#21691674121)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc