Wednesday, September 23, 2026

Stop treating your LLM agent like a chatbot and start treating it like a state machine.

Stop treating your LLM agent like a chatbot and start treating it like a state machine.

The biggest mistake developers make when building autonomous workflows is relying on prompt chaining without a robust state management layer. When you treat the agent flow as a linear sequence, a single hallucination or failed tool call breaks the entire pipeline, leading to silent failures that are impossible to debug.

Instead, implement an explicit state schema using a library like Pydantic. By defining exactly what the agent should know at each transition point, you create a checkpoint system. If the agent hits a dead end or triggers an error, you can inspect the state object to see exactly where the reasoning deviated from the intended logic.

My advice: Stop relying on the LLM to remember context across long, complex tasks. Use an external database or a key-value store to persist the agent’s state after every tool execution. This allows you to pause, resume, or replay specific segments of the workflow when things go south.

Reliability in automation doesn't come from better prompting; it comes from rigorous state transition control. How are you handling checkpointing in your current agentic workflows?

#AI #LLMs #SoftwareEngineering #AgenticWorkflows #Python

Tuesday, September 22, 2026

Most developers treat LLM tool-calling as a linear request-response loop. But if you want to build robust AI agents, you need to stop thinking about sequential chains and start thinking about stateful execution graphs.

Most developers treat LLM tool-calling as a linear request-response loop. But if you want to build robust AI agents, you need to stop thinking about sequential chains and start thinking about stateful execution graphs.

The biggest point of failure in automation workflows is the feedback loop. When an agent fails a tool execution, it often hallucinates a fix or enters a repetitive failure state.

Stop relying on simple prompt chaining. Instead, implement a self-correcting loop using a structured state machine. Define your tool output as a Pydantic model and force the agent to validate its own output against a schema before triggering the execution layer.

If the tool returns a non-zero exit code or an unexpected data format, don’t just pass the error back to the LLM. Catch it in the orchestration layer and inject a diagnostic prompt: Here is the error, here is the original goal, and here is why the previous attempt failed. Correcting the context before the next inference step increases success rates significantly.

By treating the orchestration layer as an event-driven system rather than a prompt pipeline, you gain visibility into exactly where the logic breaks.

How are you handling retries in your agent workflows? Let’s talk about your error recovery patterns below.

#AI #LLM #SoftwareEngineering #MultiAgentSystems #BuildInPublic

Monday, September 21, 2026

Most developers treat LLM tool-calling as a linear process

 Most developers treat LLM tool-calling as a linear process, but that is where your agent reliability breaks down.


When you allow an agent to call multiple tools in a single turn, the context window gets messy. The model often struggles to map output from Tool A to the input of Tool B, leading to hallucinated arguments or infinite recursion.

The fix? Shift from a single-turn "do everything" prompt to a ReAct (Reasoning and Acting) orchestration pattern.

Instead of asking the LLM to call a suite of functions at once, force a strict sequence: Thought, Action, Observation. Treat the output of each tool as a mandatory state update in your workflow.

If you are using LangChain or DSPy, implement a tool-use constraint that restricts the agent to one function call per turn. Force the model to pause, observe the result, and re-evaluate its plan. It increases latency slightly, but it decreases your error rate by an order of magnitude.

Reliability in agents isn't about better prompts. It is about tighter control over the execution loop.

How are you handling your agentic feedback loops?

Friday, June 27, 2025

NVM Activation error

When you install nvm latest verion and want to swith the node to use the latest verion , you get the activation error as below: 

>> nvm install 22.13.1 
Installation complete. If you want to use this version, 
type: nvm use 22.13.1 

>> nvm use 22.13.1

 exit status 1: 'C:\Program' is not recognized as an internal or external command, 
operable program or batch file. 
 activation error: exit status 1: 'C:\Program' is not recognized as an internal or external command, operable program or batch file.


This error is happening because your nvm is installed in a path that includes a space (like C:\Program Files\...), and it's not properly handling that space.

Here's how to fix it:

Solution: Reinstall nvm-windows to a path without spaces
Uninstall the current NVM:
Go to Add or Remove Programs and uninstall nvm.

Reinstall NVM to a space-free path:
Download the latest nvm-setup.zip from https://github.com/coreybutler/nvm-windows/releases.
During installation, change the installation path to something like:
Also set the Node.js install path to something like:

After installation, try again:

Alternative (Quick Test, not recommended long-term)
You can temporarily fix this by manually editing your settings.txt file:
Go to:
Update these paths to use short path notation (like C:\Progra~1) or better: move them to a location without spaces.

    • C:\nvm
    • C:\nodejs
  1. nvm install 22.13.1
    nvm use 22.13.1
  2. C:\Users\<YourUsername>\AppData\Roaming\nvm\settings.txt
Now check this issue, it should work fine,

Wednesday, June 18, 2025

Implementation of seamless authentication between two Laravel apps

 

When a user logs in to one application, they should also be authenticated in other application without logging in again.

1. Use a Common Authentication System

Ensure both Laravel apps share the same user database (either directly or via API).


2. Use tymon/jwt-auth in both apps

Install JWT package in both:

composer require tymon/jwt-auth
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider" php artisan jwt:secret

Do this in both apps. Say App A and App B


3. Generate Token in App A on Login

In App A, modify the login logic to generate a JWT token:

use Tymon\JWTAuth\Facades\JWTAuth;
public function login(Request $request) { $credentials = $request->only('email', 'password'); if (!$token = JWTAuth::attempt($credentials)) { return response()->json(['error' => 'Invalid credentials'], 401); } // Send token to front-end return response()->json(['token' => $token]); }

4. Share JWT Token with App B

When user logs in:

  1. Save token in a secure cookie:


return response()->json(['success' => true])->cookie( 'jwt_token', $token, 60, '/', '.seellab.com', true, true, false, 'Strict' );

✅ This cookie is available to all subdomains, like  App A and App B

  1. Alternatively, you can redirect to App B with token in query:

a
https://appbUrl/auth/jwt-login?token=xyz123

5. Accept and Authenticate in App B

In AppB, create a route like:

Route::get('/auth/jwt-login', function (Request $request) { $token = $request->get('token') ?? $request->cookie('jwt_token'); try { $user = JWTAuth::setToken($token)->authenticate(); Auth::login($user); return redirect('/dashboard'); // or wherever } catch (\Exception $e) { return redirect('/login')->withErrors('Token Invalid'); } });

You can auto-trigger this on page load, or have a middleware that checks and redirects accordingly.


6. Keep It Secure

  • Use HTTPS.

  • Mark cookie as Secure, HttpOnly, and SameSite=Strict if possible.

  • Tokens should expire, and refresh tokens can be used optionally.

  • If hosting under different domains (not subdomains), cookies won't be shareable — you'll need to redirect with the token.


Optional: Middleware in App B

Create a middleware to auto-login using the JWT cookie if user not logged in:

public function handle($request, Closure $next)
{ if (!Auth::check() && $request->cookie('jwt_token')) { try { $user = JWTAuth::setToken($request->cookie('jwt_token'))->authenticate(); Auth::login($user); } catch (\Exception $e) { // token expired or invalid } } return $next($request); }

Summary

FeatureImplementation
Token Generation            On login in App A
Token SharingSecure Cookie or URL param
Token ReadingApp B reads token from cookie/URL
Login SessionAuth::login($user) in App B
SecurityHTTPS, HttpOnly, SameSite, Token Expiry