Google I/O e IA: o que realmente muda na vida do dev?

E aí, gurizada! Deixa eu te contar uma coisa que percebi depois de tantos Google I/Os: a gente gasta uma energia absurda no “hype” e esquece de olhar o que realmente importa. Pra quem, como eu, tá com a mão na massa desenvolvendo com Inteligência Artificial, o I/O é um termômetro, sim, mas o verdadeiro teste é o que a gente consegue colocar em produção na segunda-feira. E foi exatamente isso que me motivou a gravar um vídeo assista no YouTube e agora a escrever este artigo: como a gente filtra o ruído e foca no que realmente impacta nosso dia a dia.

Desmistificando o Google I/O para Devs de IA

Eu sempre acompanho o Google I/O com um misto de expectativa e ceticismo. É inegável que o evento dita tendências e mostra a direção que o Google tá tomando em IA. Mas, como CTO, meu olhar é sempre no “e daí?”.

O que eu busco são as novidades que se traduzem em:

  • APIs e SDKs mais maduras: Menos boilerplate, mais produtividade. Se uma nova SDK me economiza horas de integração, isso sim é um ganho.
  • Otimizações em modelos existentes: Não é só sobre ter um modelo novo, mas um Gemini que custa menos pra rodar ou que entrega um resultado com 10% mais de acurácia. Isso é ouro pra quem paga a conta da infra e se preocupa com a experiência do usuário.
  • Ferramentas que resolvem a dor real: Se o I/O me apresenta uma ferramenta que simplifica o deploy de modelos ou a gestão de datasets, aí sim a conversa fica interessante. Menos tempo brigando com infra, mais tempo desenvolvendo.
  • Insights sobre a pesquisa: Às vezes, o mais valioso nem é um produto pronto, mas um paper ou uma demo que aponta pra onde o futuro da IA tá indo. Isso me ajuda a planejar os próximos passos da minha equipe e da empresa.

O que aprendi com o tempo: Foco na Aplicabilidade

No começo da minha jornada com IA, eu me empolgava com cada anúncio mirabolante. Hoje, a maturidade me trouxe uma perspectiva diferente. A pergunta que faço é sempre a mesma: “Como isso resolve um problema real do meu cliente ou do meu negócio?”.

Um exemplo prático: quando anunciam um novo modelo de linguagem gigante, minha primeira reação não é sair testando. Eu penso: “Qual o custo? Qual a latência? Ele se adapta ao meu caso de uso específico, ou vou gastar dias fazendo fine-tuning?”. Muitas vezes, um modelo menor e mais otimizado, ou até uma solução que já conheço, entrega mais valor com menos dor de cabeça. É sobre pragmatismo, gurizada.

Minha visão como CTO: Onde o I/O realmente impacta

Pra mim, o Google I/O é uma bússola. Ele mostra as direções, mas quem traça a rota somos nós. As “grandes” novidades nem sempre são as mais disruptivas no curto prazo. Às vezes, um pequeno ajuste em uma API de visão computacional ou uma melhoria na integração do Firebase com ferramentas de ML podem gerar um impacto muito maior no meu roadmap do que um anúncio de um robô que faz café.

Por isso, meu conselho é: assista aos keynotes, leia os resumos, mas depois mergulhe nos docs, faça seus próprios testes e veja o que realmente se encaixa na sua realidade. O que funciona pra um gigante da tecnologia pode não ser o ideal para o seu projeto ou startup. No meu canal e no meu blog (marcelocabral.com.br), eu sempre tento trazer essa visão prática, desmistificando o que parece complexo e focando no que realmente dá resultado.

Conclusão: Filtrando o Hype e Construindo o Futuro

O Google I/O é um evento importante, sim. Mas a nossa função como devs e líderes de tecnologia é ir além do oba-oba. É preciso discernimento para identificar o que é hype passageiro e o que é uma ferramenta robusta que realmente vai impulsionar nossos projetos e carreiras.

E você, gurizada, como filtra as novidades de eventos como o I/O? O que você busca pra decidir se uma tecnologia vale seu tempo e investimento?

When is AI fine in education?

This question is one which appears often among communities I’m part of. Many fellow students share an uncertain stance on the use of AI in programming and that’s very valid especially since many schools and institutions push the narrative: “AI is bad” or “You should not use AI or there will be consequences”. Although it can be argued that this narrative is slowly shifting towards more acceptance of AI in coding, the uncertainty has stuck and many students are confused on how to use it in order to reach a perfect balance of learning and support.

My Personal Stance

Personally I think the educational narrative of “AI is bad” is flat out incorrect. I have used many different AI models to help me revise, refine ideas, and learn new concepts and it has helped me in each of those areas tremendously. A great example of this is an exam on certain topics and programming concepts in C which I had just over a week ago. My friend and I had just spent the week before trying to finish a 4,000 word essay and had very little time to revise so 2 hours prior to the exam we pulled up GLM 5.1 and prompted the model to provide us with 50 questions relating to lecture slides which we provided it. After 2 hours of going through the questions, researching topics we struggled with, and trying to cram as much as possible we felt very confident going into the exam. We both left the exam with a score of 86% each which felt great.

That wasn’t my only recent experience using AI productively, I’ve also leveraged AI to help me structure the aforementioned 4,000 word essay and although I am yet to receive results for it I felt confident that it met the requirements of the mark scheme and guidelines. In fact I’d say it tremendously increased my productivity as I didn’t have to concern myself with how to structure the essay but instead aim all my focus at writing code and the content of the essay itself.

My Recommended Best Practices:

In my opinion it’s easy to cross a line using AI and have it write all your work and code but that’s counterproductive due to a lack of challenge and actual learning. If you put no care or effort into it then you ultimately learn very little to nothing.

Firstly, you should rarely if ever have AI write an entire piece of work for you. Instead have it structure your essays or help plan out your coding tasks into easy to understand steps. This allows you to focus on the main body of your work and increase productivity substantially.

Secondly, always provide the model with your course handbooks and assignment briefs/guidelines. This way you don’t waste time typing out a long prompt explaining the entire assignment and also provides the model with the exact and fully accurate information it needs to help you plan your work.

Thirdly, if you are revising for an exam always prompt the AI to teach you and quiz you until your quiz answers are adequate. By doing this you won’t get walls of boring text and actually allow yourself to practice. Pairing this with the previous tip will allow you to revise extremely efficiently and you’ll be surprised with the progress you make after an hour.

Conclusion

Institutions claiming “Using AI is wrong and dishonest” do not understand how beneficial AI can be if you use it appropriately and are ultimately falling behind. If you’re a student yourself and struggle to find the right balance using AI models then the above advice should help you get there. Obviously feel free to experiment with different prompting styles and methods but the above tips have worked incredibly well for me.

Please feel free to let me know of any tips you may have in the comments and any feedback you may have for my tips.

Python Tools for Managing API Rate Limits in Data Pipelines

data center server rack ethernet cables close

Handling HTTP 429 Too Many Requests responses correctly in Python data pipelines requires more than a time.sleep(1) in an except block. The following tools and libraries are the practical toolkit for building rate limit resilience into production data automation. They cover everything from simple retry decorators to distributed rate limiting for multi-worker pipelines.

1. Tenacity

What it does: A Python retry library that provides a decorator-based interface for configuring retry behavior, backoff strategies, and logging.

Why it matters: Rolling your own exponential backoff is straightforward for simple cases, but production pipelines need configurable stop conditions, structured logging of retry attempts, and clean separation between business logic and retry behavior. Tenacity handles all of these.

Installation:

pip install tenacity

Basic usage for API rate limits:

from tenacity import (
    retry,
    stop_after_attempt,
    wait_exponential_jitter,
    retry_if_exception_type,
    before_sleep_log,
)
import logging

logger = logging.getLogger(__name__)

@retry(
    retry=retry_if_exception_type(RateLimitError),
    wait=wait_exponential_jitter(initial=1, max=60),
    stop=stop_after_attempt(6),
    before_sleep=before_sleep_log(logger, logging.WARNING),
)
def call_api(url, session):
    response = session.get(url, timeout=30)
    if response.status_code == 429:
        raise RateLimitError(response.headers.get("Retry-After"))
    response.raise_for_status()
    return response

Best for: Any production pipeline that makes retried API calls. The before_sleep_log parameter in particular is valuable for operations monitoring — you get a WARNING log entry before every retry, making it easy to set up alerts when retry rates increase.

GitHub: jd/tenacity | Documentation

2. Requests with Session Reuse

What it does: The requests library’s Session object reuses TCP connections across requests, significantly reducing overhead in high-volume API calls.

Why it matters: Each new requests.get() call opens a new TCP connection. At 100 requests per second, this overhead adds up. A Session object maintains a connection pool that reuses established connections, reducing latency and server load.

import requests

with requests.Session() as session:
    session.headers.update({"Authorization": "Bearer TOKEN"})
    session.headers.update({"User-Agent": "MyPipeline/1.0"})

    for url in url_list:
        response = session.get(url, timeout=30)
        # process response

Best for: Any pipeline making multiple calls to the same API host. The combination of session reuse and rate limiting is the baseline for efficient API automation.

Documentation: requests.readthedocs.io

data center server rack ethernet cables close
Photo by Brett Sayles on Pexels

3. PyRateLimit / ratelimit

What it does: A simple decorator library for rate limiting function calls. Enforces a maximum number of calls per time period.

Installation:

pip install ratelimit

Usage:

from ratelimit import limits, sleep_and_retry

CALLS_PER_SECOND = 10
ONE_SECOND = 1

@sleep_and_retry
@limits(calls=CALLS_PER_SECOND, period=ONE_SECOND)
def fetch(url, session):
    return session.get(url, timeout=30)

The @sleep_and_retry decorator combined with @limits creates a proactive rate limiter: when the call limit is reached, it sleeps until the window resets rather than raising an exception. This prevents most 429 responses from occurring rather than recovering from them.

Limitations: This library is effective for single-process pipelines but does not coordinate state across multiple workers or processes. For distributed pipelines, you need shared state (see Redis below).

PyPI: pypi.org/project/ratelimit

4. Redis-Based Distributed Rate Limiting

What it does: Uses Redis as a shared rate limit counter across multiple workers, enabling coordinated rate limiting in distributed pipelines.

Why it matters: A token bucket or rate limiter that lives in a single Python process is correct for single-worker pipelines. When you have 10 workers making concurrent requests, each with its own in-process rate limiter, the total request rate will be 10x the per-worker limit. Shared Redis state ensures the total rate is correct regardless of worker count.

Basic pattern using redis-py:

import redis
import time

r = redis.Redis(host="localhost", port=6379)

def acquire_token(key, limit, window_seconds):
    """Sliding window rate limiter backed by Redis."""
    now = time.time()
    pipe = r.pipeline()

    # Remove old entries outside the window
    pipe.zremrangebyscore(key, 0, now - window_seconds)
    # Count current entries
    pipe.zcard(key)
    # Add current request timestamp
    pipe.zadd(key, {str(now): now})
    # Set TTL to clean up automatically
    pipe.expire(key, window_seconds + 1)

    results = pipe.execute()
    current_count = results[1]

    if current_count >= limit:
        return False  # Rate limit exceeded
    return True

Best for: Multi-worker or multi-machine pipelines where coordination of API usage across processes is required.

5. httpx with AsyncClient

What it does: An async HTTP client with request/response API compatible with requests, supporting async/await for concurrent API calls.

Why it matters: asyncio-based pipelines can make many concurrent API calls efficiently without multi-threading overhead. httpx integrates cleanly with tenacity for async retry:

import httpx
from tenacity import retry, stop_after_attempt, wait_exponential_jitter

@retry(
    wait=wait_exponential_jitter(initial=1, max=60),
    stop=stop_after_attempt(5),
)
async def async_fetch(client, url):
    response = await client.get(url, timeout=30.0)
    if response.status_code == 429:
        raise RateLimitError(response.headers.get("Retry-After"))
    response.raise_for_status()
    return response

async def batch_fetch(urls, headers):
    async with httpx.AsyncClient(headers=headers) as client:
        tasks = [async_fetch(client, url) for url in urls]
        return await asyncio.gather(*tasks, return_exceptions=True)

Caveat: Async concurrency increases the rate at which you consume API quota. Pair httpx with an async-compatible rate limiter (aiolimiter is one option) to avoid immediately hitting limits with the increased concurrency.

6. Monitoring: Structlog for Retry Visibility

What it does: A structured logging library that produces machine-readable log output, making retry events easier to query and alert on.

Why it matters: Knowing that your pipeline is retrying is only useful if you are notified when retry rates increase. Structlog output integrates cleanly with log aggregation systems (Datadog, CloudWatch, Grafana Loki) where you can set alerts on retry event counts.

import structlog

log = structlog.get_logger()

def log_rate_limit_event(response, wait_seconds):
    log.warning(
        "rate_limit_encountered",
        status_code=response.status_code,
        retry_after=response.headers.get("Retry-After"),
        x_ratelimit_remaining=response.headers.get("X-RateLimit-Remaining"),
        wait_seconds=round(wait_seconds, 1),
    )

Each retry event emits a structured log record with all the context needed to diagnose pattern changes: which endpoint, how long the wait, how many tokens remain. This is the observability layer that turns rate limit handling from a fire-and-forget implementation into a monitored pipeline component.

fiber optic cable glow blue network rack
Photo by Suki Lee on Pexels

Testing Rate Limit Handling

Rate limit handling code is only as good as its test coverage. Three approaches for testing retry logic without hitting a live API:

Mock the response object: Use unittest.mock.patch to replace requests.Session.get with a function that returns a mock response with status_code=429 for the first N calls, then 200 thereafter. This verifies that your retry loop executes the correct number of retries and calls the wait function with the expected arguments.

httpbin: httpbin.org/status/429 returns a real 429 response, letting you verify that your Retry-After parsing and backoff logic work against a live endpoint without consuming your actual API quota.

Local proxy: A local reverse proxy (nginx, mitmproxy) configured to inject 429 responses at a configured rate lets you test the full pipeline behavior — including session reuse, token bucket throttling, and retry logging — under simulated rate limit conditions.

Choosing the Right Combination

For most Python data automation pipelines, the practical starting point is:

  • tenacity for retry logic (reactive)
  • ratelimit or a hand-rolled token bucket for rate throttling (proactive)
  • requests Session for connection efficiency
  • Structured logging for observability

For distributed pipelines with multiple workers:

  • Add Redis for shared rate limit state across workers
  • Consider httpx + asyncio for high-concurrency fetch patterns

The full implementation of these patterns — including a complete working example combining tenacity, token bucket, and session reuse — is covered in How to Handle API Rate Limits in Python Data Automation.

For production data pipeline work where rate limit resilience is a design requirement from day one, visit https://137foundry.com/services/data-automation.

How to Implement Exponential Backoff for Rate-Limited APIs in Python

server rack cables data center close

Hitting an API rate limit and not knowing what to do with the HTTP 429 response is one of the most common causes of brittle data automation scripts. This is a step-by-step implementation guide: from a minimal correct backoff function to a production-grade tenacity decorator that logs retries, handles Retry-After headers, and distinguishes between retriable and non-retriable errors.

What We Are Building

By the end of this guide, you will have:

  1. A calculate_wait() function that reads Retry-After headers when present and falls back to exponential backoff with jitter when not
  2. A fetch_with_backoff() wrapper function for single requests
  3. A tenacity-based decorator for production use with logging
  4. A proactive TokenBucket class to prevent most 429 responses before they occur

Prerequisites: Python 3.8+, requests and tenacity installed:

pip install requests tenacity

Step 1: Parse the Retry-After Header

The most important piece of rate limit handling is honoring the API’s own signal about when to retry. Many 429 responses include a Retry-After header that tells you exactly how long to wait.

import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime

def parse_retry_after(headers):
    """
    Parse the Retry-After header from a rate-limited response.
    Returns seconds to wait, or None if the header is absent.
    """
    retry_after = headers.get("Retry-After")
    if not retry_after:
        return None

    # Some APIs return seconds as a plain integer string
    try:
        return max(0.0, float(retry_after))
    except ValueError:
        pass

    # Others return an HTTP date string: "Wed, 21 Oct 2015 07:28:00 GMT"
    try:
        reset_dt = parsedate_to_datetime(retry_after)
        now = datetime.now(timezone.utc)
        return max(0.0, (reset_dt - now).total_seconds())
    except Exception:
        return None

Step 2: Build the Wait Calculation Function

Combine Retry-After parsing with exponential backoff as the fallback:

import random

def calculate_wait(response, attempt, base=1.0, max_delay=60.0):
    """
    Calculate how long to wait before retrying a failed request.
    Uses Retry-After header when available, exponential backoff otherwise.
    """
    api_specified = parse_retry_after(response.headers)
    if api_specified is not None:
        return api_specified

    # Exponential backoff with jitter
    delay = min(base * (2 ** attempt), max_delay)
    jitter = random.uniform(0, delay * 0.1)
    return delay + jitter

The jitter term prevents the thundering herd problem: if multiple workers all hit the limit at the same moment, jitter ensures they do not all retry at exactly the same moment.

Step 3: Write the Retry Wrapper

A minimal correct implementation with explicit handling for 429 vs. server errors vs. client errors:

import requests

def fetch_with_backoff(url, headers=None, max_retries=6, base_delay=1.0):
    """
    Make a GET request with retry logic for 429 and 5xx responses.
    Does not retry on 4xx client errors (except 429).
    """
    for attempt in range(max_retries):
        response = requests.get(url, headers=headers or {}, timeout=30)

        if response.status_code == 200:
            return response

        if response.status_code == 429:
            if attempt == max_retries - 1:
                raise RuntimeError(f"Rate limit persists after {max_retries} retries: {url}")
            wait = calculate_wait(response, attempt, base=base_delay)
            print(f"Rate limited (429). Waiting {wait:.1f}s (attempt {attempt + 1}/{max_retries})")
            time.sleep(wait)
            continue

        if response.status_code >= 500:
            if attempt == max_retries - 1:
                response.raise_for_status()
            wait = min(base_delay * (2 ** attempt), 60.0)
            print(f"Server error ({response.status_code}). Waiting {wait:.1f}s")
            time.sleep(wait)
            continue

        # 4xx client errors: do not retry
        response.raise_for_status()

    raise RuntimeError(f"Exhausted retries for {url}")

This handles the three distinct cases: rate limits (retry with API-specified or backoff delay), server errors (retry with backoff), and client errors (fail immediately without retrying).

server rack cables data center close
Photo by QuinceCreative on Pixabay

Step 4: Production-Grade Retry with Tenacity

The tenacity library provides a decorator-based retry system that is cleaner to configure and includes built-in logging:

from tenacity import (
    retry,
    stop_after_attempt,
    wait_exponential_jitter,
    retry_if_exception_type,
    before_sleep_log,
)
import logging
import requests

logger = logging.getLogger(__name__)

class RateLimitError(Exception):
    pass

class ServerError(Exception):
    pass

def raise_for_status_with_retry(response):
    """Convert HTTP errors to typed exceptions for tenacity."""
    if response.status_code == 429:
        raise RateLimitError(
            f"Rate limited. Retry-After: {response.headers.get('Retry-After', 'not specified')}"
        )
    if response.status_code >= 500:
        raise ServerError(f"Server error {response.status_code}")
    response.raise_for_status()
    return response

@retry(
    retry=retry_if_exception_type((RateLimitError, ServerError)),
    wait=wait_exponential_jitter(initial=1, max=60),
    stop=stop_after_attempt(6),
    before_sleep=before_sleep_log(logger, logging.WARNING),
    reraise=True,
)
def fetch_api_resource(url, session):
    response = session.get(url, timeout=30)
    return raise_for_status_with_retry(response)

The before_sleep_log parameter writes a WARNING entry to your log system before each sleep interval, which makes retry behavior visible in logs without requiring custom logging code in the retry loop.

Step 5: Add Proactive Rate Limiting with Token Bucket

Exponential backoff is reactive: it handles failures after they occur. A token bucket implementation is proactive: it throttles your own request rate to stay below the API limit, reducing how often 429 responses occur.

import threading

class TokenBucket:
    """Thread-safe token bucket for rate limiting API requests."""

    def __init__(self, rate, capacity):
        self.rate = rate          # tokens added per second
        self.capacity = capacity  # maximum tokens
        self.tokens = float(capacity)
        self.last_refill = time.monotonic()
        self._lock = threading.Lock()

    def acquire(self, tokens=1):
        """Wait until tokens are available. Returns the actual wait time."""
        with self._lock:
            now = time.monotonic()
            elapsed = now - self.last_refill
            self.tokens = min(self.capacity, self.tokens + elapsed * self.rate)
            self.last_refill = now

            if self.tokens >= tokens:
                self.tokens -= tokens
                return 0.0

            wait = (tokens - self.tokens) / self.rate
            self.tokens = 0
            return wait

# For an API allowing 10 requests per second:
bucket = TokenBucket(rate=10, capacity=10)

def throttled_fetch(url, session):
    wait = bucket.acquire()
    if wait > 0:
        time.sleep(wait)
    return fetch_api_resource(url, session)

Putting It Together

A complete paginated API consumer that combines proactive throttling and reactive retry:

import requests

bucket = TokenBucket(rate=5, capacity=10)  # Stay under the API limit

def paginate_api(base_url, auth_headers, params=None):
    results = []
    page = 1

    with requests.Session() as session:
        session.headers.update(auth_headers)

        while True:
            url = f"{base_url}?page={page}&per_page=100"
            response = throttled_fetch(url, session)

            data = response.json()
            items = data.get("items") or data.get("results") or []

            if not items:
                break

            results.extend(items)
            page += 1

    return results

The token bucket prevents most 429 responses. The tenacity decorator handles the ones that slip through. The session reuses the TCP connection across requests.

Error Categories to Handle Differently

Not all errors should be retried. A well-structured retry strategy distinguishes:

Status Code Meaning Action
429 Rate limited Retry after wait
500, 502, 503, 504 Server error Retry with backoff
401, 403 Auth failure Fail immediately — credentials are wrong
400 Bad request Fail immediately — the request itself is invalid
404 Not found Fail immediately — the resource does not exist

Retrying on 401 or 400 is always wrong and wastes time. A correct implementation routes each error type to the appropriate response.

circuit board chip macro close up
Photo by blickpixel on Pixabay

Testing Your Retry Logic

Retry logic is difficult to test without a server that deliberately returns 429 responses. Options:

Mock the response object: Use unittest.mock.patch to replace requests.get with a function that returns a mock response with status_code=429 for the first N calls.

Use a local proxy: Run a local reverse proxy (nginx, mitmproxy) in front of the API that injects 429 responses at a configured rate.

Use httpbin: httpbin.org/status/429 returns a 429 response that you can use to test parsing and backoff behavior without hitting a real API.

For the complete guide including token bucket implementation details, tenacity configuration for production pipelines, and monitoring recommendations, read the full article here.

“My Web Chat Wasn’t a Real Channel. That Broke My Agent Pipeline”

I thought my web chat was the simplest surface in the whole product.

Telegram, Feishu, and DingTalk were the complicated ones. Web chat was just the dashboard. Same browser, same server, same app. What could possibly go wrong?

A lot, apparently.

The bug looked random from the UI

A task would start from the web chat UI just fine.

The runtime session existed. The conversation existed. The task existed. The logs looked healthy enough.

And then the delivery pipeline tried to send a follow-up update back into the conversation and got:

conversation_not_found

Which made no sense, because the conversation definitely existed. I had just used it.

This is the kind of bug that wastes time because every individual subsystem looks half-correct.

The real problem: I treated web chat like a page, not a channel

The architecture in CliGate already had a channel model.

Telegram is a channel. Feishu is a channel. DingTalk is a channel.

Those inbound messages go through the same supervision and delivery machinery:

  • conversation store
  • scheduler
  • delivery sender
  • assistant orchestration
  • runtime session binding

But web chat had slowly drifted into a special-case path.

That felt harmless at first. Web chat lived inside the same app, so it was easy to give it a little custom state and a few convenience wrappers.

That was the mistake.

What actually broke

The old version of chat-ui/conversation-store.js exported its own store instance.

Meanwhile, the delivery and orchestration path used the shared channel conversation store.

So both sides were reading and writing “conversations,” but not the same in-memory array.

That meant:

  • the chat UI could create a conversation
  • the route handler could see it
  • the runtime could bind to it
  • but the scheduler could still fail to find it later

The comments in the fix say it more plainly than I can:

// chat-ui and agent-channels each held a SEPARATE in-memory
// `conversations` array, even though both wrote to the same JSON file on disk.
// After server start, a chat-ui conversation created at runtime was visible to
// chat-ui-route but NOT to message-service, so scheduler deliveries hit
// `conversation_not_found` and silently dropped notifications.

That is exactly the sort of bug you get when a “small UI shortcut” quietly forks your domain model.

The fix was not complicated

I did not need a new abstraction.

I needed one source of truth.

Instead of exporting a dedicated chat-ui conversation store in production, I attached chat-specific helpers to the shared singleton used by the channel system:

installChatUiHelpers(agentChannelConversationStore);

export const chatUiConversationStore = agentChannelConversationStore;

That one change matters more than it looks.

Now web chat is not pretending to be adjacent to the channel system. It is part of the channel system.

Why this changed more than delivery

Once I stopped treating web chat as a special page, a lot of other decisions became cleaner.

A chat-ui conversation now behaves like a real peer of the other channels:

  • it has the same conversation identity model
  • it uses the same assistant delivery state
  • it flows through the same runtime binding logic
  • it can receive scheduler-driven updates without weird bridging code

That matters because a multi-surface assistant only stays sane if all entry points agree on what a conversation is.

If one surface has its own special rules, you do not have one product anymore. You have one product plus one exception that keeps leaking.

The other important fix: seed assistant mode from the start

There was a second detail hidden in the same file.

New chat-ui conversations now start with assistant control mode already set:

assistantCore: buildAssistantCoreDeliveryState(
  existingAssistantCore,
  { controlMode: CONVERSATION_ASSISTANT_CONTROL_MODE.ASSISTANT }
)

That matters because web chat should enter the same top-level assistant orchestration path as the messaging channels.

If the first message from the web UI skips that and goes straight to the bound runtime, you get behavioral drift:

  • web chat behaves one way
  • Telegram behaves another way
  • Feishu behaves another way

Then every bug becomes impossible to reason about because the surfaces are no longer comparable.

The test I actually wanted

I have learned to distrust fixes like this unless there is a test that proves the behavioral contract.

The right question was not “does chat-ui store still work?”

The right question was:

does a chat-ui conversation participate in assistant behavior like a real channel?

That is why the surrounding tests focus on assistant-mode behavior and persisted conversation semantics instead of only checking helper methods in isolation.

The implementation detail was a store instance bug.

The product bug was channel inconsistency.

What I learned from this

When you build multi-channel agent systems, the browser UI is seductive.

It feels local. It feels simple. It feels close enough to the app that you can justify giving it custom flow control, custom state, or custom routing.

That instinct is expensive.

If the browser chat can start tasks, receive async updates, carry conversation identity, and interact with the same supervisor as your mobile or messaging surfaces, then it is not “just a page.”

It is a channel.

And if you do not model it that way, the architecture will eventually make you pay for the lie.

Are you treating your web chat as a first-class channel, or as a special case that has not failed loudly yet?

Repo: github.com/codeking-ai/cligate

next-advanced-sitemap v1.0.7 — safer URL ingestion & automatic trimming for Next.js sitemap generation

next-advanced-sitemap v1.0.7 is now available.

This release improves ingestion resilience by automatically sanitizing invisible leading and trailing spaces before validation and XML generation.

What’s included in v1.0.7:

  • Automatic .trim() sanitization for:

    • Primary URLs
    • Hreflang alternates
    • Image sitemap entries
    • Video sitemap metadata
  • Silent correction of accidental spacing issues caused by:

    • CMS content
    • Markdown ingestion
    • Copy/paste mistakes
    • Distributed data pipelines
  • Strict validation remains intact:

    Invalid internal URL spacing still correctly triggers validation failures.

Why this matters:

Large-scale Next.js applications often ingest URLs from databases, CMS platforms, APIs, or Markdown files. Small formatting inconsistencies can unexpectedly break sitemap generation or XML compilation pipelines.

v1.0.7 prevents these issues automatically while preserving strict structural validation.

Features:

  • Google Images support
  • Google Video support
  • Google News support
  • Hreflang / multilingual SEO
  • App Router support
  • Type-safe configuration
  • Zero dependencies

Install:

npm install next-advanced-sitemap

NPM:
https://www.npmjs.com/package/next-advanced-sitemap

GitHub:
https://github.com/fomadev/next-advanced-sitemap

I keep seeing people build an AI lead processing agent when they really need a 6-step rules engine

I knew this was worth writing when I saw a Reddit thread describing an “AI lead processing agent” for underwriting.

The job sounded fancy until you translated it into actual steps:

  1. Watch an inbox
  2. Extract business name + monthly deposits
  3. Check Salesforce, HubSpot, or a custom CRM/CMR
  4. See whether the lead already exists
  5. Route to new banks if needed
  6. Assign a rep only if deposits are over $30,000

That is not an agent problem.

That is workflow logic with one messy-input step.

And a commenter in r/openclaw said the quiet part out loud:

Don’t use AI for deterministic processing. You can write a simple script for this and it will be much more reliable and cheaper.

I think that’s exactly right.

The mistake: using an LLM as a decision engine

A lot of teams are building “AI lead gen automation” that should really be split into two pieces:

  • fuzzy extraction
  • deterministic state transitions

Those are not the same thing.

If the input is ugly — forwarded email chains, scanned PDFs, weird broker notes, inconsistent merchant statements — then yes, use Claude, GPT-5, or Qwen to extract fields.

But once you have the fields, stop asking the model to make business decisions that can be expressed as code.

Bad pattern:

  • “Figure out whether this is a duplicate”
  • “Decide whether to assign a rep”
  • “Determine which bank should receive this”

Better pattern:

  • model extracts business_name, monthly_deposits, contact_email
  • code checks CRM state
  • code applies explicit rules
  • code writes the result atomically

That split matters a lot in production.

The architecture I’d actually ship

If I were building underwriting intake or lead routing, I’d use this shape:

  1. Trigger on inbound email/webhook
  2. Parse sender/subject/attachments deterministically
  3. Send only messy text to an LLM for strict extraction
  4. Normalize extracted values
  5. Check CRM using normalized identifiers
  6. In one locked step, decide duplicate/new/assignment
  7. Only after the write succeeds, trigger downstream actions

That gives you a small LLM boundary and a deterministic core.

Put the LLM in a tiny box

The safest contract is something boring like this:

{
  "business_name": "Blue Lantern LLC",
  "monthly_deposits": 35000,
  "contact_email": "[email protected]",
  "requested_amount": 50000,
  "confidence": 0.91
}

That’s a good use of GPT-5, Claude Sonnet, or Qwen.

What I would not do is this:

Read the email, decide if the lead is a duplicate, determine whether it qualifies for rep assignment, and choose which bank should receive it.

That prompt looks convenient right up until you need consistency, auditability, and duplicate prevention.

What actually breaks first in production

Not the prompt.

Concurrency.

This is where agent demos usually lie to you. They work great with one email.

Then two brokers forward the same merchant 20 seconds apart.

Now both workers do this:

  • query CRM
  • see no assigned record yet
  • decide the lead is new
  • route it
  • create duplicate work

That’s not an AI failure. That’s a race condition.

And no amount of “reasoning” fixes a missing transaction boundary.

The rule that matters more than your prompt

If your flow includes duplicate checks, threshold-based assignment, or bank routing, the critical part is the write path.

This logic should be explicit:

def process_lead(crm_record_exists, new_banks_available, monthly_deposits):
    if crm_record_exists:
        if new_banks_available:
            return "route_to_new_banks"
        return "mark_duplicate_internal"

    if monthly_deposits >= 30000:
        return "assign_rep_and_send_docs"

    return "mark_low_revenue"

And the final decision should happen inside one transaction or locked operation.

For example, in PostgreSQL:

BEGIN;

SELECT id
FROM leads
WHERE normalized_business_name = $1
FOR UPDATE;

-- if exists, update state
-- if not, insert new row with unique constraint protection

COMMIT;

Or with an upsert:

INSERT INTO leads (normalized_business_name, contact_email, monthly_deposits, status)
VALUES ($1, $2, $3, $4)
ON CONFLICT (normalized_business_name)
DO UPDATE SET updated_at = NOW()
RETURNING id, status;

That is the part worth obsessing over.

Not whether your agent sounds confident while making inconsistent choices.

A practical hybrid design

This is the version I’d recommend to most teams using n8n, Make, Zapier, OpenClaw, or custom Python/TypeScript workers.

Layer What it should do
Trigger/orchestration Watch inboxes, webhooks, retries, notifications
LLM step Extract fields from messy email/PDF text
Normalization step Clean business names, parse currency, standardize email/domain
Rules engine Apply deposit thresholds, duplicate policy, assignment logic
Transaction-safe write Insert/update CRM state atomically
Downstream actions Send docs, notify reps, route to banks

This is what “AI where it helps, code where it matters” actually looks like.

Example: n8n + Python worker

If I wanted to move fast, I’d use n8n for orchestration and a small Python service for the transaction-sensitive part.

n8n flow

  • IMAP Email Trigger or webhook
  • extract attachments/text
  • LLM node for structured extraction
  • HTTP request to internal worker
  • Slack/email notification after successful write

Python worker sketch

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class LeadPayload(BaseModel):
    business_name: str
    monthly_deposits: float
    contact_email: str
    requested_amount: float | None = None

@app.post("/process-lead")
def process_lead(payload: LeadPayload):
    normalized_name = payload.business_name.strip().lower()

    # pseudo-code for transaction-safe logic
    # begin transaction
    # lock matching lead row or rely on unique constraint
    # check duplicate/new bank state
    # apply 30k threshold
    # write final status
    # commit transaction

    if payload.monthly_deposits >= 30000:
        return {"status": "assign_rep_and_send_docs"}

    return {"status": "mark_low_revenue"}

That gives you a workflow people can reason about.

It also makes debugging possible when something goes wrong at 9:12 a.m. on a Monday.

Where AI does help

I’m not arguing against LLMs here.

I’m arguing against giving them the wrong job.

Good uses in this flow:

  • extracting fields from ugly broker emails
  • parsing scanned PDFs or OCR output
  • summarizing long email threads for a rep
  • drafting a reply asking for missing docs
  • flagging low-confidence extractions for human review

Bad uses in this flow:

  • duplicate detection when the criteria are known
  • rep assignment when the threshold is explicit
  • bank routing when policy is fixed
  • deciding whether CRM state “probably means” something

The moment a rule can be written down, it should stop being an LLM decision.

The cost problem gets ugly fast

There’s another reason to avoid agent-first design: cost creep.

I saw another Reddit comment from someone using OpenClaw who said summarizing the last 10 emails with Claude 4.6 Sonnet cost about $0.25.

That sounds tiny.

Until your “agent” is doing that kind of work all day across:

  • inbox triage
  • CRM re-checks
  • duplicate review
  • status summaries
  • follow-up drafts
  • lead routing decisions that should have been simple SQL or code

That’s how teams end up saying their agent stack burns tokens faster than expected.

The model is doing office work your rules engine should be doing for free.

This is exactly why predictable pricing matters if you’re running automations 24/7. If your workflows call models constantly, per-token billing turns every design mistake into a monthly surprise. Standard Compute is interesting here because it gives you an OpenAI-compatible API with flat monthly pricing, so you can afford to use models for the messy extraction layer without constantly watching token spend. That doesn’t mean you should waste LLM calls on deterministic routing. It means you can use AI where it actually helps and keep the rest of the pipeline boring.

Agent-first vs automation-first

Approach What usually happens
Automation-first Deterministic branching, explicit thresholds, atomic writes, easier debugging
Agent-first More token usage, inconsistent decisions, harder audits, race-condition blind spots
Hybrid LLM for extraction/summaries, code for rules and state transitions

If you remember one thing, make it this:

Using an LLM for extraction is not the same as handing control to an agent.

Those are completely different design choices.

A concrete test

Before you add an AI agent to a workflow, ask:

What part of this flow is genuinely ambiguous?

If the answer is:

  • “the email is messy”
  • “the PDF format is inconsistent”
  • “the broker note is hard to parse”

Use Claude, GPT-5, Grok, or Qwen for extraction.

If the answer is:

  • “check the CRM”
  • “apply the $30k rule”
  • “avoid duplicates”
  • “assign the right rep”
  • “route to the right bank”

You do not need autonomy.

You need explicit logic.

My opinionated version

Most underwriting intake automations are not agent problems.

They are data integrity problems wearing an AI costume.

The messy-input layer is where AI earns its keep.

The state-transition layer is where software engineering still wins.

So if you’re building this in n8n, Make, Zapier, OpenClaw, or custom code, keep the model on a short leash:

  • extract
  • classify uncertainty
  • draft summaries
  • stop there

Then let your rules engine do the real work.

That may be less exciting than saying you built an autonomous underwriting agent.

It also sounds a lot more like something I’d trust with real leads.

AI Powered Student Learning Assistant Using Gemma 4

This is a submission for the Gemma 4 Challenge

What I Built

I built a Smart Study Assistant using Gemma 4 that helps students learn more efficiently. The assistant can summarize notes, answer questions, create quizzes, and explain difficult topics in simple language.

The goal is to reduce study stress and provide quick learning support for students.

Demo

The assistant allows users to:

  • Upload study notes
  • Get summaries
  • Ask questions
  • Generate quizzes
  • Receive easy explanations

Code

Repository: https://github.com/harshilthakkar49-tech/smart-study-assistant

How I Used Gemma 4

I used Gemma 4 because of its strong reasoning capabilities and efficient performance. Gemma helps process educational content and provide understandable responses.
The model improves learning by:

  • Understanding student questions
  • Simplifying complex topics
  • Generating practice content
  • Supporting personalized learning
    Gemma 4 was the right fit because it balances performance and accessibility.

Future Improvements

  • Voice interaction
  • Multi-language support
  • Personalized study plans
  • Mobile app integration

Thanks for reading!

How I Built a Drop-In Proxy to Slash My OpenAI Bills by 20%+ Automatically

Every developer building with Large Language Models eventually hits the same painful reality: the API bill always catches up to you. Between massive system instructions, multi-turn chat histories, and heavy Retrieval-Augmented Generation (RAG) contexts, prompt sizes explode fast. And since LLM providers charge you per token for every single request, you are constantly paying a premium for linguistic filler words (the, is, and, available) that the AI models don’t even need to understand your intent.

I wanted a way to automatically strip out prompt waste and cut my API costs without rewriting my entire application logic.

So, I built and shipped llm-cost-optimizer-node—a zero-config, drop-in client wrapper that intercepts outgoing messages, optimizes them in the cloud, and pipes them seamlessly to your LLM provider.

The Architecture: How it Works Under the Hood

The entire philosophy of this tool is zero structural friction. Instead of forcing you to manually pass every string through an optimization utility before a fetch request, it acts as a local proxy wrapper around your initialized client instance.

  1. Intercept: The wrapper captures the outgoing payload right as chat.completions.create is fired.

  2. Optimize: It securely runs the text blocks through an engine to handle minification, stop-word stripping, or stemming.

  3. Log & Pipe: It prints the exact token savings straight to your development terminal and forwards the lean prompt to the LLM.

Show Me the Code

Integrating it takes exactly three lines of code. You wrap your native client instance once, and leave the rest of your codebase completely untouched.

const { OpenAI } = require('openai');
const { wrapClient } = require('llm-cost-optimizer-node');

// 1. Initialize and wrap your standard client instance
const openai = wrapClient(new OpenAI({ apiKey: process.env.OPENAI_API_KEY }), {
    rapidApiKey: process.env.RAPID_API_KEY,
    strategy: ["minify", "strip_stopwords"] 
});

// 2. Run your existing production code exactly as before!
const response = await openai.chat.completions.create({
    model: "gpt-4o",
    messages: [
        { role: "system", content: "You are a warehouse assistant." },
        { role: "user", content: "The ergonomic office chair is highly accessible and available in warehouse-4 right now." }
    ]
});

🟢 The Terminal Output

The moment that request executes, your console streams live telemetry showing you exactly how much money and context window you just saved:

--- [Optimizer Proxy] Intercepting Outgoing Messages... ---
🟢 [Metrics] Msg 0 | Slashed: 35 -> 28 tokens (20.00% Saved)

Engineering for Production: Fail-Safe Execution

When building developer infrastructure, application uptime is non-negotiable. I didn’t want a network hiccup or an expired API key to crash a production system.

To solve this, the SDK is built with a strict fail-safe guardrail loop:

try {
    const compressed = await callOptimizationEngine(text);
    return compressed;
} catch (error) {
    console.warn(`⚠️ [Optimizer Proxy Warning] Compression failed: ${error.message}`);
    return originalText; // Transparent fallback fallback execution
}

If your network goes down or the gateway API hits a rate limit, the client wrapper instantly catches the exception, prints a subtle warning to your server logs, and safely drops back to forwarding your original untouched prompt to your LLM provider. Your application production uptime remains completely bulletproof.

Try It Out!

The package is fully open-source and live on the global npm registry right now.

I’m currently working on adding specialized optimization profiles for heavy RAG workflows and complex Agent state loops.

I’d love to hear your thoughts! What optimization strategies are you using to keep your production LLM bills under control? Drop a comment below!