USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeAll BooksAI Agent Book
HomeAI Agent BookFoundations
PreviousWhat Is an AI Harness?NextModels, Messages, Instructions, and Context
AI NOTICE: This is the table of contents for the SPECIFIC CHAPTER only. It is NOT the global sidebar. For all chapters, look at the main navigation.

On this page

11 sections

Progress0%
1 / 11

Muhammad Usman Akbar Entity Profile

Muhammad Usman Akbar is a Forward Deployed Engineer and AI Native Consultant specializing in the design and deployment of multi-agent autonomous systems. Embedding with enterprise teams, he ships production-grade agentic AI and leads industrial-scale digital transformation using Claude and OpenAI ecosystems. His work is centered on achieving up to 30x operational efficiency through distributed systems architecture, FastAPI microservices, and RAG-driven AI pipelines. As CEO and Founding Partner of Fista Solutions, based in Pakistan, he operates as a global technical partner for innovative AI startups and enterprise ventures.

USMAN’S INSIGHTS
AI ARCHITECT

Transforming businesses into autonomous AI ecosystems. Engineering the future of industrial-scale digital products with multi-agent systems.

30X Growth
AI-First
Innovation

Navigation

  • Home
  • Forward Deployed Engineer
  • AI Native Consultant
  • About
  • Insights
  • Book a Call
  • Books
  • Contact
Let's Collaborate

Have a Project in Mind?

Let's build something extraordinary together. Transform your vision into autonomous AI reality.

Start Your Transformation

© 2026 Muhammad Usman Akbar. All rights reserved.

Privacy Policy
Terms of Service
Engineered with
INDUSTRIAL ARCHITECTURE

Python and TypeScript Essentials for Agent Builders

Agent SDKs are ordinary libraries built around asynchronous I/O, typed data, environment configuration, and streamed events. You do not need language mastery to begin, but you must understand functions, collections, exceptions, async iteration, schemas, and package isolation well enough to distinguish your code from provider behavior.

What will you be able to do?

You will create isolated Python and TypeScript projects, load credentials from the process environment, read async code, and handle a stream without swallowing failures.

Why are the examples Python-first?

Python gives beginners a compact continuous path. TypeScript appears when browser/server ecosystems, Zod schemas, or SDK differences matter. The architecture is language-neutral: types, policies, events, and idempotency exist in both.

How do you create safe project environments?

Python:

bash
mkdir supportops && cd supportops python3 -m venv .venv source .venv/bin/activate python -m pip install --upgrade pip

TypeScript:

bash
mkdir supportops-ts && cd supportops-ts npm init -y npm pkg set type=module npm install --save-dev typescript tsx @types/node

Commit lockfiles. Do not commit .env, virtual environments, node_modules, traces with sensitive data, or provider credentials.

What does asynchronous code mean?

Agent runs wait on networks, tools, processes, and streams. Async code lets one process make progress elsewhere while waiting.

async_basics.py:

python
import asyncio async def fetch_ticket(ticket_id: str) -> dict[str, str]: await asyncio.sleep(0.01) # Represents network I/O. return {"id": ticket_id, "subject": "Refund not received"} async def main() -> None: ticket = await fetch_ticket("T-100") print(ticket["subject"]) if __name__ == "__main__": asyncio.run(main())

TypeScript expresses the same shape with Promise, async, and await. Streams from both SDKs often use async iteration:

typescript
async function* events(): AsyncGenerator<string> { yield "run.started"; yield "run.completed"; } for await (const event of events()) { console.log(event); }

How should you handle configuration and errors?

Read required credentials once at application startup and fail with a useful message:

python
import os def required_env(name: str) -> str: value = os.getenv(name) if not value: raise RuntimeError(f"Missing required environment variable: {name}") return value

Catch an exception only where you can add context, retry safely, translate it into a domain error, or clean up a resource. Preserve the original cause:

python
try: ticket = await fetch_ticket("T-100") except TimeoutError as error: raise RuntimeError("Ticket lookup exceeded its 2-second deadline") from error

Never log environment values to prove they loaded.

How do you prove your setup works?

  1. Run the async example and see the subject.
  2. Unset a required test variable and confirm startup fails clearly.
  3. Add a timeout and confirm the original error remains chained.
  4. Run a formatter, type checker, and a one-test suite before installing an agent SDK.

Failure injection: Misspell one dictionary key and let your type checker or test catch it. The lesson is not the typo; it is that deterministic defects should fail before they reach a paid model call.

What mistakes should you avoid?

  • Running pip outside the intended virtual environment.
  • Mixing CommonJS and ES modules without understanding the boundary.
  • Calling asyncio.run() from inside an already running event loop.
  • Printing raw SDK messages that may contain sensitive content.
  • Using broad except Exception: pass blocks.

Check your understanding

  1. Why do agent SDKs use async iterators?
  2. Where should a missing credential fail?
  3. When is catching an exception justified?

Expert extension

Create a tiny typed event stream in both languages. Add cancellation, a timeout, and a test that proves cleanup still runs when the consumer stops early.

Official references

  • Python asyncio
  • TypeScript documentation