Nam Hoai Nguyen's Notes

website·Indexed 29 days ago

https://www.namhoainguyen.com

A collection of personal technical notes and guides covering a variety of tools and technologies, including Git, Docker, Tailwind CSS, PHPStorm, VS Code, macOS installation, and the OpenClaw architecture from the book AI Agents in Depth.

Tokens
11.6K
Snippets
65
Records
91
Agent score
45%

What's inside Nam Hoai Nguyen's Notes

  1. Understand Docker basic concepts and common flags

    Docker is an open-source virtualization technology used to build, test, and deploy applications within container environments that include all necessary tools, configurations, and code. Common CLI flags include:

    • -i (interactive): Used with docker exec or docker run to keep STDIN open.
    • -t (terminal): Allocates a pseudo-TTY.
    • -m (memory): Limits memory usage.
    • -v (volume): Mounts volumes between the host and container.
    • --rm: Automatically removes the container after it exits.
  2. Design Real-Time Multimodal Agent Interactions

    To move beyond sequential turn-taking, agents should implement an Asynchronous Event-Driven Architecture using an internal Event Queue and Event Bus to handle real-time triggers (webhooks, interrupts) and support state serialization via trajectory preservation.

    For voice interaction, the evolution moves from a 'Traditional Cascade Pipeline' (VAD -> ASR -> LLM -> TTS) which suffers from high accumulated latency, toward 'Omnimodal End-to-End' models and 'Full-Duplex Communication' to allow natural user interruptions.

    For physical/digital interaction:

    • Computer Use: Uses visual grounding and click/type action spaces on virtual screens.
    • Robotics: Uses Vision-Language-Action (VLA) models and Sim2Real transfer to move policies from simulation to reality.
  3. Compare giscus and utterances for GitHub comments

    When choosing a GitHub-based comment system, giscus is generally preferred over utterances for the following reasons:

    • Maintenance: giscus is actively maintained, whereas utterances is not.
    • Backend: giscus utilizes GitHub Discussions, while utterances uses GitHub Issues.
    • Features: giscus supports threaded replies in comments; utterances does not.
    • Integration: giscus provides wrappers for popular frameworks, while utterances relies on plain JavaScript requiring manual implementation.
  4. Design a two-layer Agent memory architecture

    To maintain persistent cross-session memory and prevent context rot, implement a two-layer system:

    1. Resident Layer (L0/L1): Active, persistent profiles using Advanced JSON Cards containing immutable user traits, kept permanently in the active context.
    2. Retrieval Layer (L2): Raw historic interaction trajectories stored in a database and fetched via Contextual Retrieval as needed.
  5. Implement the OpenClaw Agent Architecture

    The OpenClaw architecture integrates Deep Research, Computer Use, and Programming. It leverages programming as a 'meta-capability' to achieve rigorous logic (verifying reasoning via code execution), Generative UI (dynamic rendering with auto-repair via console logs), and Agent Bootstrapping (where a parent agent writes code to spawn and debug child agents).

    The architecture utilizes 7 general-purpose tools:

    • Python Sandbox
    • Bash Shell
    • Read File
    • Write File
    • Edit File (diff-based)
    • Glob
    • Grep
  6. Implement Continual Self-Evolution for Agents

    Agents can evolve without constant weight updates using a dual-loop architecture and four update carriers:

    Update CarrierContent UpdatedTarget Scenario
    Experience BaseMarkdown SOPs, success/failure casesFactual business rules
    Prompt & SkillSystem-level instructionsConceptual thinking rules
    Program (Workflow)Hard-coded scriptsRepeatable procedures
    Model ParametersSFT/DPO gold trajectoriesStylistic/reasoning habits

    To ensure stability, use 'Sleep Learning':

    • Online Execution Loop: Executes tasks and writes immutable raw trajectories.
    • Offline Consolidation Loop: Reviews trajectories, resolves contradictions, and runs regression tests during idle time.

    Critical Constraint: The 'Root-of-Trust Boundary' prohibits the agent from modifying its own validation criteria (test cases, release thresholds) to prevent artificial progress reporting.

  7. Initialize a new Astro project

    To start a new Astro project, ensure Node.js is installed and run the official creation command. Follow the prompts provided by the CLI and the specific installation steps for your chosen theme.
    npm create astro@latest
  8. Manage git submodules

    Git submodules allow you to keep one repository as a subdirectory of another. You can configure git to automatically recurse into submodules during clones and pulls.
    # Automatically update submodules on clone/pull
    git config --global submodule.recurse true
    
    # Add a new submodule
    git submodule add <url>
    
    # Initialize and update submodules for the first time
    git submodule update --init --recursive
    
    # Update submodules from remote
    git submodule update --recursive --remote
    
    # Clone a repo including its submodules
    git clone <repo> --recursive
    
    # Remove a submodule (located at a/submodule)
    git submodule deinit -f -- a/submodule
    rm -rf .git/modules/a/submodule
    git rm -f a/submodule
    git rm --cached a/submodule
  9. Manage Git ignore files and local change assumptions

    Create a .gitignore file to exclude files/folders from version control. Use update-index to tell Git to ignore local changes to a file without adding it to .gitignore.
    # Add file/folder to .gitignore
    echo file.txt >> .gitignore
    
    # Mark file as unchanged (ignore local changes during pull/push)
    git update-index --assume-unchanged <file>
    
    # Undo assume-unchanged
    git update-index --no-assume-unchanged <file>
    
    # List all files currently marked as assume-unchanged
    git ls-files -v | grep '^h'
  10. Use Sass for styling in Astro

    Install the sass module to enable Sass compilation. You can use Sass for component-level styles or global styles using the lang="sass" attribute in style tags.
    npm install sass
    <!-- Component-level Sass -->
    <style lang="sass">
     // write code here
    </style>
    
    <!-- Global Sass -->
    <style is:global lang="sass">
     // write code here
    </style>
  11. Design and secure Agent tools

    Tools are classified into three types: Perception (acquiring state, e.g., web search), Execution (modifying state, e.g., bash commands), and Collaboration (managing sub-Agents).

    Implementation Standards:

    • Model Context Protocol (MCP): Use this standardized client-server protocol to ensure tools are plug-and-play across different front-ends (e.g., Cursor, Claude Desktop).
    • Security: Mitigate Prompt Injection and RCE by executing code in isolated, ephemeral sandboxes (gVisor, WebAssembly, or firewalled containers) using an 'Execute - Verify - Feedback' loop.