posted an update —

Learning Proposal Based on the recent successful resolution of the live LinkedIn publishing pipeline and NLM Brain integration, here is the proposal to persist reusable operational learnings and guardrails.

  1. Context & Incident Analysis What Happened Hardcoded Fallbacks & Missing Imports: NLMBrainBridge in linkedin_automation/core/nlm_bridge.py contained a hardcoded stale NOTEBOOK_ID fallback (7c85c185-28bb-4585-b77f-987d3f3dabfb) instead of reading NLM_NOTEBOOK_ID from .env. Additionally, import os was missing at top-level module scope, resulting in a NameError: name 'os' is not defined when evaluating os.getenv() at class declaration time. Successful Resolution: Added import os to top-level imports in nlm_bridge.py. Updated NLMBrainBridge to dynamically bind self.notebook_id = notebook_id or os.getenv("NLM_NOTEBOOK_ID", DEFAULT_ID). Verified end-to-end execution in LIVE mode (dry_run=False), successfully publishing post urn:li:share:7491299620556419072 to LinkedIn API v2.
  2. Classification & Scope Type: Rule (Invariant Guardrail) Target Location: .agents/rules/linkedin-nlm-automation.md (Workspace-level) Scope: Reusable rules for NLM Brain Bridge, environment loading, and LinkedIn API execution across this workspace.
  3. Proposed Rule Content markdown

Rule: LinkedIn & NLM Bridge Automation Standards

1. Dynamic Environment Binding

  • No Hardcoded Notebook IDs: NLMBrainBridge and related agents MUST load NLM_NOTEBOOK_ID dynamically from environment variables (os.getenv("NLM_NOTEBOOK_ID")).
  • Import Hygiene: All standard library modules (os, json, subprocess, logging, time, pathlib) referenced in module/class definitions MUST be imported at the top of the file before class definition evaluation.
  • Dotenv Initialization: Entry points (main.py, mcp_server.py, standalone runner scripts) MUST execute load_dotenv(dotenv_path) before instantiating bridges or agents. ## 2. Live API Execution Safeguards
  • Live Publishing Flag: Live LinkedIn posts require LINKEDIN_ACCESS_TOKEN and LINKEDIN_PERSON_URN in .env, with dry_run=False explicitly passed.
  • NLM Query Timeouts & Polling: Respect rate limiting (QUERY_DELAY >= 2.0s) and subprocess timeout (timeout=120s) when invoking nlm notebook query to prevent hanging CLI execution.
  • Next Steps Upon your approval of this proposal, I will create .agents/rules/linkedin-nlm-automation.md in the workspace to lock in these rules for all future agent tasks.

Log in or sign up for Devpost to join the conversation.